mirror of
https://github.com/exyte/Macaw.git
synced 2024-09-21 18:09:21 +03:00
Stroke line width and color animation support
This commit is contained in:
parent
da3d1f4238
commit
e47b230b82
@ -103,13 +103,38 @@ fileprivate func generateShapAnimation(from:Shape, to: Shape, duration: Double,
|
|||||||
let fromPath = RenderUtils.toCGPath(from.form).copy(using: &transform)
|
let fromPath = RenderUtils.toCGPath(from.form).copy(using: &transform)
|
||||||
let toPath = RenderUtils.toCGPath(to.form).copy(using: &transform)
|
let toPath = RenderUtils.toCGPath(to.form).copy(using: &transform)
|
||||||
|
|
||||||
|
let group = CAAnimationGroup()
|
||||||
|
|
||||||
let pathAnimation = CABasicAnimation(keyPath: "path")
|
let pathAnimation = CABasicAnimation(keyPath: "path")
|
||||||
pathAnimation.fromValue = fromPath
|
pathAnimation.fromValue = fromPath
|
||||||
pathAnimation.toValue = toPath
|
pathAnimation.toValue = toPath
|
||||||
pathAnimation.duration = duration
|
pathAnimation.duration = duration
|
||||||
|
|
||||||
let group = CAAnimationGroup()
|
group.animations = [pathAnimation]
|
||||||
group.animations = [pathAnimation]
|
|
||||||
|
// Stroke
|
||||||
|
if let fromStroke = from.stroke, let toStroke = to.stroke {
|
||||||
|
// Line width
|
||||||
|
let strokeWidthAnimation = CABasicAnimation(keyPath: "lineWidth")
|
||||||
|
strokeWidthAnimation.fromValue = fromStroke.width
|
||||||
|
strokeWidthAnimation.toValue = toStroke.width
|
||||||
|
strokeWidthAnimation.duration = duration
|
||||||
|
|
||||||
|
group.animations?.append(strokeWidthAnimation)
|
||||||
|
|
||||||
|
// Line color
|
||||||
|
if let fromColor = fromStroke.fill as? Color, let toColor = toStroke.fill as? Color{
|
||||||
|
let strokeColorAnimation = CABasicAnimation(keyPath: "strokeColor")
|
||||||
|
strokeColorAnimation.fromValue = RenderUtils.mapColor(fromColor)
|
||||||
|
strokeColorAnimation.toValue = RenderUtils.mapColor(toColor)
|
||||||
|
strokeColorAnimation.duration = duration
|
||||||
|
|
||||||
|
group.animations?.append(strokeColorAnimation)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
group.duration = duration
|
group.duration = duration
|
||||||
group.fillMode = kCAFillModeForwards
|
group.fillMode = kCAFillModeForwards
|
||||||
group.isRemovedOnCompletion = false
|
group.isRemovedOnCompletion = false
|
||||||
|
Loading…
Reference in New Issue
Block a user