-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from p-x9/feature/animation
CAAnimation
- Loading branch information
Showing
33 changed files
with
1,322 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
{ | ||
"class": "CAReplicatorLayer", | ||
"layerModel": { | ||
"sublayers": [ | ||
{ | ||
"layerModel": { | ||
"position": [ | ||
100, | ||
100 | ||
], | ||
"bounds": [ | ||
[ | ||
0, | ||
0 | ||
], | ||
[ | ||
200, | ||
200 | ||
] | ||
], | ||
"animations": { | ||
"ripple": { | ||
"class": "CAAnimationGroup", | ||
"animationModel": { | ||
"beginTime": 0, | ||
"duration": 3, | ||
"timeOffset": 0, | ||
"autoreverses": false, | ||
"fillMode": { | ||
"rawValue": "removed" | ||
}, | ||
"isRemovedOnCompletion": false, | ||
"speed": 1, | ||
"repeatDuration": 0, | ||
"repeatCount": 3.4028235e+38, | ||
"animations": [ | ||
{ | ||
"animationModel": { | ||
"autoreverses": false, | ||
"repeatDuration": 0, | ||
"timeOffset": 0, | ||
"fillMode": { | ||
"rawValue": "forwards" | ||
}, | ||
"isRemovedOnCompletion": false, | ||
"fromValue": { | ||
"type": "float", | ||
"value": 0 | ||
}, | ||
"speed": 1, | ||
"isAdditive": false, | ||
"duration": 3, | ||
"repeatCount": 0, | ||
"isCumulative": false, | ||
"toValue": { | ||
"value": 1, | ||
"type": "int" | ||
}, | ||
"keyPath": "transform.scale.xy", | ||
"beginTime": 0 | ||
}, | ||
"class": "CABasicAnimation" | ||
}, | ||
{ | ||
"class": "CAKeyframeAnimation", | ||
"animationModel": { | ||
"repeatCount": 0, | ||
"repeatDuration": 0, | ||
"keyPath": "opacity", | ||
"fillMode": { | ||
"rawValue": "forwards" | ||
}, | ||
"beginTime": 0, | ||
"isCumulative": false, | ||
"calculationMode": { | ||
"rawValue": "linear" | ||
}, | ||
"autoreverses": false, | ||
"isRemovedOnCompletion": false, | ||
"keyTimes": [ | ||
0, | ||
0.5, | ||
1 | ||
], | ||
"values": [ | ||
{ | ||
"type": "float", | ||
"value": 0.8 | ||
}, | ||
{ | ||
"type": "float", | ||
"value": 0.4 | ||
}, | ||
{ | ||
"type": "float", | ||
"value": 0 | ||
} | ||
], | ||
"isAdditive": false, | ||
"speed": 1, | ||
"timeOffset": 0, | ||
"duration": 3 | ||
} | ||
} | ||
], | ||
"timingFunction": "linear" | ||
} | ||
} | ||
}, | ||
"backgroundColor": { | ||
"code": "FF00FFFF" | ||
}, | ||
"allowsEdgeAntialiasing": false, | ||
"contentsFormat": { | ||
"rawValue": "RGBA8" | ||
}, | ||
"cornerRadius": 100, | ||
"opacity": 0, | ||
"allowsGroupOpacity": true | ||
}, | ||
"class": "CALayer" | ||
} | ||
], | ||
"instanceCount": 3, | ||
"contentsFormat": { | ||
"rawValue": "RGBA8" | ||
}, | ||
"allowsEdgeAntialiasing": false, | ||
"instanceDelay": 1, | ||
"position": [ | ||
196.5, | ||
426 | ||
], | ||
"bounds": [ | ||
[ | ||
0, | ||
0 | ||
], | ||
[ | ||
200, | ||
200 | ||
] | ||
], | ||
"allowsGroupOpacity": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// CAMediaTimingFunction+.swift | ||
// | ||
// | ||
// Created by p-x9 on 2024/04/06. | ||
// | ||
// | ||
|
||
import QuartzCore | ||
|
||
extension CAMediaTimingFunction { | ||
var controlPoints: [CGPoint] { | ||
var controlPoints = [CGPoint]() | ||
for index in 1..<3 { | ||
let controlPoint = UnsafeMutablePointer<Float>.allocate(capacity: 2) | ||
getControlPoint(at: Int(index), values: controlPoint) | ||
let x: Float = controlPoint[0] | ||
let y: Float = controlPoint[1] | ||
controlPoint.deallocate() | ||
controlPoints.append(CGPoint(x: CGFloat(x), y: CGFloat(y))) | ||
} | ||
return controlPoints | ||
} | ||
|
||
var name: CAMediaTimingFunctionName? { | ||
switch description { | ||
case "linear": .linear | ||
case "easeIn": .easeIn | ||
case "easeOut": .easeOut | ||
case "easeInEaseOut": .easeInEaseOut | ||
case "default": .default | ||
default: nil | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
Sources/SDCALayer/Extension/IndirectlyCodable/Animation/CAAnimation+ICodable.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// CAAnimation+ICodable.swift | ||
// | ||
// | ||
// Created by p-x9 on 2024/04/06. | ||
// | ||
// | ||
|
||
import QuartzCore | ||
import IndirectlyCodable | ||
|
||
extension CAAnimation: IndirectlyCodable { | ||
public typealias Model = JCAAnimation | ||
|
||
public func codable() -> JCAAnimation? { | ||
guard let animationClass = NSClassFromString(Self.codableTypeName) as? JCAAnimation.Type else { | ||
return nil | ||
} | ||
|
||
return animationClass.init(with: self) | ||
} | ||
|
||
@objc | ||
open class var codableTypeName: String { | ||
String(reflecting: Model.self) | ||
} | ||
} | ||
|
||
extension CAMediaTimingFillMode: RawIndirectlyCodable { | ||
public typealias Model = JCAMediaTimingFillMode | ||
} |
17 changes: 17 additions & 0 deletions
17
Sources/SDCALayer/Extension/IndirectlyCodable/Animation/CAAnimationGroup+ICodable.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// CAAnimationGroup+ICodable.swift | ||
// | ||
// | ||
// Created by p-x9 on 2024/04/07. | ||
// | ||
// | ||
|
||
import QuartzCore | ||
|
||
extension CAAnimationGroup { | ||
public typealias Model = JCAAnimationGroup | ||
|
||
open override class var codableTypeName: String { | ||
String(reflecting: Model.self) | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Sources/SDCALayer/Extension/IndirectlyCodable/Animation/CABasicAnimation+ICodable.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// CABasicAnimation+ICodable.swift | ||
// | ||
// | ||
// Created by p-x9 on 2024/04/07. | ||
// | ||
// | ||
|
||
import QuartzCore | ||
|
||
extension CABasicAnimation { | ||
public typealias Model = JCABasicAnimation | ||
|
||
open override class var codableTypeName: String { | ||
String(reflecting: Model.self) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
Sources/SDCALayer/Extension/IndirectlyCodable/Animation/CAKeyframeAnimation+ICodable.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// CAKeyframeAnimation+ICodable.swift | ||
// | ||
// | ||
// Created by p-x9 on 2024/04/07. | ||
// | ||
// | ||
|
||
import QuartzCore | ||
|
||
extension CAKeyframeAnimation { | ||
public typealias Model = JCAKeyframeAnimation | ||
|
||
open override class var codableTypeName: String { | ||
String(reflecting: Model.self) | ||
} | ||
} | ||
|
||
extension CAAnimationCalculationMode: RawIndirectlyCodable { | ||
public typealias Model = JCAAnimationCalculationMode | ||
} | ||
|
||
extension CAAnimationRotationMode: RawIndirectlyCodable { | ||
public typealias Model = JCAAnimationRotationMode | ||
} |
17 changes: 17 additions & 0 deletions
17
Sources/SDCALayer/Extension/IndirectlyCodable/Animation/CAPropertyAnimation+ICodable.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// CAPropertyAnimation+ICodable.swift | ||
// | ||
// | ||
// Created by p-x9 on 2024/04/07. | ||
// | ||
// | ||
|
||
import QuartzCore | ||
|
||
extension CAPropertyAnimation { | ||
public typealias Model = JCAPropertyAnimation | ||
|
||
open override class var codableTypeName: String { | ||
String(reflecting: Model.self) | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Sources/SDCALayer/Extension/IndirectlyCodable/Animation/CASpringAnimation+ICodable.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// CASpringAnimation+ICodable.swift | ||
// | ||
// | ||
// Created by p-x9 on 2024/04/09. | ||
// | ||
// | ||
|
||
import QuartzCore | ||
|
||
extension CASpringAnimation { | ||
public typealias Model = JCASpringAnimation | ||
|
||
open override class var codableTypeName: String { | ||
String(reflecting: Model.self) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
Sources/SDCALayer/Extension/IndirectlyCodable/CAMediaTimingFunction+ICodable.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// CAMediaTimingFunction+ICodable.swift | ||
// | ||
// | ||
// Created by p-x9 on 2024/04/07. | ||
// | ||
// | ||
|
||
import QuartzCore | ||
import IndirectlyCodable | ||
|
||
extension CAMediaTimingFunction: IndirectlyCodable { | ||
public typealias Model = JCAMediaTimingFunction | ||
|
||
public func codable() -> Model? { | ||
.init(with: self) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
Sources/SDCALayer/Extension/IndirectlyCodable/CAValueFunction+ICodable.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// CAValueFunction+ICodable.swift | ||
// | ||
// | ||
// Created by p-x9 on 2024/04/07. | ||
// | ||
// | ||
|
||
import QuartzCore | ||
import IndirectlyCodable | ||
|
||
extension CAValueFunction: IndirectlyCodable { | ||
public typealias Model = JCAValueFunction | ||
|
||
public func codable() -> Model? { | ||
.init(with: self) | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.