Skip to content

Commit

Permalink
More API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
f3dm76 committed Aug 6, 2020
1 parent b4feb66 commit 4a7049e
Showing 1 changed file with 11 additions and 58 deletions.
69 changes: 11 additions & 58 deletions Source/animation/types/ShapeAnimation.swift
Original file line number Diff line number Diff line change
@@ -66,85 +66,38 @@ class ShapeAnimation: AnimationImpl<Shape> {
}

public extension AnimatableVariable where T == Stroke? {
func animate<T: Stroke>(from: T? = nil, to: T, during: Double = 1.0, delay: Double = 0.0) {
let shape = node as! Shape

var safeFrom = from
if safeFrom == nil {
if let shapeStroke = shape.stroke as? T {
safeFrom = shapeStroke
} else {
safeFrom = Stroke(width: 1.0) as? T
}
}

shape.stroke = safeFrom

func animate(from: Stroke? = nil, to: Stroke, during: Double = 1.0, delay: Double = 0.0) {
let shape = node as! Shape
shape.stroke = from ?? (shape.stroke ?? Stroke(width: 1.0))
let finalShape = SceneUtils.shapeCopy(from: shape)
finalShape.stroke = to

_ = ShapeAnimation(animatedNode: shape, finalValue: finalShape, animationDuration: during, delay: delay, autostart: true)
}

func animation<T: Stroke>(from: T? = nil, to: T, during: Double = 1.0, delay: Double = 0.0) -> Animation {
func animation(from: Stroke? = nil, to: Stroke, during: Double = 1.0, delay: Double = 0.0) -> Animation {
let shape = node as! Shape

var safeFrom = from
if safeFrom == nil {
if let shapeStroke = shape.stroke as? T {
safeFrom = shapeStroke
} else {
safeFrom = Stroke(width: 1.0) as? T
}
}

shape.stroke = safeFrom

shape.stroke = from ?? (shape.stroke ?? Stroke(width: 1.0))
let finalShape = SceneUtils.shapeCopy(from: shape)
finalShape.stroke = to

return ShapeAnimation(animatedNode: shape, finalValue: finalShape, animationDuration: during, delay: delay, autostart: false)
}
}

public extension AnimatableVariable where T == Fill? {
func animate<T: Fill>(from: T? = nil, to: T, during: Double = 1.0, delay: Double = 0.0) {
let shape = node as! Shape

var safeFrom = from
if safeFrom == nil {
if let shapeFill = shape.fill as? T {
safeFrom = shapeFill
} else {
safeFrom = Color.clear as? T
}
}

shape.fill = safeFrom

func animate(from: Fill? = nil, to: Fill, during: Double = 1.0, delay: Double = 0.0) {
let shape = node as! Shape
shape.fill = from ?? (shape.fill ?? Color.clear)
let finalShape = SceneUtils.shapeCopy(from: shape)
finalShape.fill = to

_ = ShapeAnimation(animatedNode: shape, finalValue: finalShape, animationDuration: during, delay: delay, autostart: true)
}

func animation<T: Fill>(from: T? = nil, to: T, during: Double = 1.0, delay: Double = 0.0) -> Animation {
func animation(from: Fill? = nil, to: Fill, during: Double = 1.0, delay: Double = 0.0) -> Animation {
let shape = node as! Shape

var safeFrom = from
if safeFrom == nil {
if let shapeFill = shape.fill as? T {
safeFrom = shapeFill
} else {
safeFrom = Color.clear as? T
}
}

shape.fill = safeFrom

shape.fill = from ?? (shape.fill ?? Color.clear)
let finalShape = SceneUtils.shapeCopy(from: shape)
finalShape.fill = to

return ShapeAnimation(animatedNode: shape, finalValue: finalShape, animationDuration: during, delay: delay, autostart: false)
}
}

0 comments on commit 4a7049e

Please sign in to comment.