mirror of
https://github.com/exyte/Macaw.git
synced 2024-09-11 13:15:35 +03:00
Update minimum deployment version of ios to 11.0
This commit is contained in:
parent
3622eafde9
commit
65f358425f
@ -530,7 +530,7 @@
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = FZXCM5CJ7P;
|
||||
INFOPLIST_FILE = Example/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.exyte.Example.Example;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@ -550,7 +550,7 @@
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = FZXCM5CJ7P;
|
||||
INFOPLIST_FILE = Example/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.exyte.Example.Example;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
@ -17,7 +17,7 @@ Pod::Spec.new do |s|
|
||||
s.source = { :git => 'https://github.com/exyte/Macaw.git', :tag => s.version.to_s }
|
||||
s.social_media_url = 'http://exyte.com'
|
||||
|
||||
s.ios.deployment_target = "9.0"
|
||||
s.ios.deployment_target = "11.0"
|
||||
s.osx.deployment_target = "10.12"
|
||||
s.requires_arc = true
|
||||
s.swift_version = "5.3"
|
||||
|
@ -677,14 +677,14 @@
|
||||
A7B47E44230EA402009DD7E5 /* Graphics_iOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = A718CD451F45C28700966E06 /* Graphics_iOS.swift */; };
|
||||
A7B47E45230EA404009DD7E5 /* Common_iOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = A718CD431F45C28200966E06 /* Common_iOS.swift */; };
|
||||
A7E675561EC4213500BD9ECB /* NodeBoundsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7E675551EC4213500BD9ECB /* NodeBoundsTests.swift */; };
|
||||
A7F46DEA270B2219008DA1DF /* CommonError.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7F46DE9270B2219008DA1DF /* CommonError.swift */; };
|
||||
A7F46DEB270B2219008DA1DF /* CommonError.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7F46DE9270B2219008DA1DF /* CommonError.swift */; };
|
||||
A7F46DE0270B0EE8008DA1DF /* XMLHash.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7F46DDD270B0EE8008DA1DF /* XMLHash.swift */; };
|
||||
A7F46DE1270B0EE8008DA1DF /* XMLHash.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7F46DDD270B0EE8008DA1DF /* XMLHash.swift */; };
|
||||
A7F46DE2270B0EE8008DA1DF /* shim.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7F46DDE270B0EE8008DA1DF /* shim.swift */; };
|
||||
A7F46DE3270B0EE8008DA1DF /* shim.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7F46DDE270B0EE8008DA1DF /* shim.swift */; };
|
||||
A7F46DE4270B0EE8008DA1DF /* XMLIndexer+XMLIndexerDeserializable.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7F46DDF270B0EE8008DA1DF /* XMLIndexer+XMLIndexerDeserializable.swift */; };
|
||||
A7F46DE5270B0EE8008DA1DF /* XMLIndexer+XMLIndexerDeserializable.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7F46DDF270B0EE8008DA1DF /* XMLIndexer+XMLIndexerDeserializable.swift */; };
|
||||
A7F46DEA270B2219008DA1DF /* CommonError.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7F46DE9270B2219008DA1DF /* CommonError.swift */; };
|
||||
A7F46DEB270B2219008DA1DF /* CommonError.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7F46DE9270B2219008DA1DF /* CommonError.swift */; };
|
||||
C410148E1F834D290022EE44 /* style.svg in Resources */ = {isa = PBXBuildFile; fileRef = C410148D1F834D280022EE44 /* style.svg */; };
|
||||
C4153A8F1F8793DE001BA5EE /* small-logo.png in Resources */ = {isa = PBXBuildFile; fileRef = C4153A8E1F8793DD001BA5EE /* small-logo.png */; };
|
||||
C46E83551F94B20E00208037 /* transform.svg in Resources */ = {isa = PBXBuildFile; fileRef = C46E83541F94B20E00208037 /* transform.svg */; };
|
||||
@ -1262,10 +1262,10 @@
|
||||
A74C832B229FB7690085A832 /* color-prop-04-t-manual-osx.svg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "color-prop-04-t-manual-osx.svg"; sourceTree = "<group>"; };
|
||||
A74C832D229FBA4C0085A832 /* color-prop-04-t-manual-osx.reference */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "color-prop-04-t-manual-osx.reference"; sourceTree = "<group>"; };
|
||||
A7E675551EC4213500BD9ECB /* NodeBoundsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NodeBoundsTests.swift; path = Bounds/NodeBoundsTests.swift; sourceTree = "<group>"; };
|
||||
A7F46DE9270B2219008DA1DF /* CommonError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonError.swift; sourceTree = "<group>"; };
|
||||
A7F46DDD270B0EE8008DA1DF /* XMLHash.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XMLHash.swift; sourceTree = "<group>"; };
|
||||
A7F46DDE270B0EE8008DA1DF /* shim.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = shim.swift; sourceTree = "<group>"; };
|
||||
A7F46DDF270B0EE8008DA1DF /* XMLIndexer+XMLIndexerDeserializable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "XMLIndexer+XMLIndexerDeserializable.swift"; sourceTree = "<group>"; };
|
||||
A7F46DE9270B2219008DA1DF /* CommonError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonError.swift; sourceTree = "<group>"; };
|
||||
C410148D1F834D280022EE44 /* style.svg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = style.svg; sourceTree = "<group>"; };
|
||||
C4153A8E1F8793DD001BA5EE /* small-logo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "small-logo.png"; sourceTree = "<group>"; };
|
||||
C43B064C1F9738EF00787A35 /* clip.svg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = clip.svg; sourceTree = "<group>"; };
|
||||
@ -3205,6 +3205,7 @@
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = NO;
|
||||
INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "";
|
||||
OTHER_SWIFT_FLAGS = "-D CARTHAGE";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.exyte.Macaw;
|
||||
@ -3230,6 +3231,7 @@
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = NO;
|
||||
INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "";
|
||||
OTHER_SWIFT_FLAGS = "-D CARTHAGE";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.exyte.Macaw;
|
||||
@ -3253,6 +3255,7 @@
|
||||
"$(SDKROOT)",
|
||||
);
|
||||
INFOPLIST_FILE = MacawTests/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.exyte.MacawTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@ -3276,6 +3279,7 @@
|
||||
"$(SDKROOT)",
|
||||
);
|
||||
INFOPLIST_FILE = MacawTests/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.exyte.MacawTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
@ -6,7 +6,7 @@ let package = Package(
|
||||
name: "Macaw",
|
||||
platforms: [
|
||||
.macOS(.v10_12),
|
||||
.iOS(.v9)
|
||||
.iOS(.v11)
|
||||
],
|
||||
products: [
|
||||
.library(
|
||||
|
@ -100,7 +100,7 @@ We're working hard to provide full documentation. Currently you can take a look
|
||||
|
||||
## Requirements
|
||||
|
||||
* iOS 9.0+
|
||||
* iOS 11.0+
|
||||
* Mac OS X 10.11+
|
||||
* Xcode 7.3+
|
||||
|
||||
|
@ -20,34 +20,34 @@ public class Animation {
|
||||
}
|
||||
|
||||
public func state() -> AnimationState {
|
||||
return .initial
|
||||
.initial
|
||||
}
|
||||
|
||||
public func easing(_ easing: Easing) -> Animation {
|
||||
return self
|
||||
self
|
||||
}
|
||||
|
||||
public func delay(_ delay: Double) -> Animation {
|
||||
return self
|
||||
self
|
||||
}
|
||||
|
||||
public func cycle(_ count: Double) -> Animation {
|
||||
return self
|
||||
self
|
||||
}
|
||||
|
||||
public func cycle() -> Animation {
|
||||
return self
|
||||
self
|
||||
}
|
||||
|
||||
public func reverse() -> Animation {
|
||||
return self
|
||||
self
|
||||
}
|
||||
|
||||
public func autoreversed() -> Animation {
|
||||
return self
|
||||
self
|
||||
}
|
||||
|
||||
@discardableResult public func onComplete(_: @escaping (() -> Void)) -> Animation {
|
||||
return self
|
||||
self
|
||||
}
|
||||
}
|
||||
|
@ -136,10 +136,10 @@ class BasicAnimation: Animation {
|
||||
}
|
||||
|
||||
override open func reverse() -> Animation {
|
||||
return self
|
||||
self
|
||||
}
|
||||
|
||||
func getDuration() -> Double { return 0 }
|
||||
func getDuration() -> Double { 0 }
|
||||
}
|
||||
|
||||
// MARK: - Hashable
|
||||
@ -150,14 +150,14 @@ extension BasicAnimation: Hashable {
|
||||
}
|
||||
|
||||
public static func == (lhs: BasicAnimation, rhs: BasicAnimation) -> Bool {
|
||||
return lhs.ID == rhs.ID
|
||||
lhs.ID == rhs.ID
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Activity
|
||||
extension BasicAnimation {
|
||||
func isActive() -> Bool {
|
||||
return progress > 0.0 && progress < 1.0
|
||||
progress > 0.0 && progress < 1.0
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,6 +284,6 @@ open class AnimationDescription <T> {
|
||||
}
|
||||
|
||||
open func t(_ duration: Double, delay: Double = 0.0) -> AnimationDescription<T> {
|
||||
return AnimationDescription(valueFunc: valueFunc, duration: duration, delay: delay)
|
||||
AnimationDescription(valueFunc: valueFunc, duration: duration, delay: delay)
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import Foundation
|
||||
class AbsoluteUtils {
|
||||
|
||||
class func absolutePosition(_ nodeRenderer: NodeRenderer?, _ context: AnimationContext) -> Transform {
|
||||
return AbsoluteUtils.absoluteTransform(nodeRenderer, context, pos: nodeRenderer?.node.place ?? .identity)
|
||||
AbsoluteUtils.absoluteTransform(nodeRenderer, context, pos: nodeRenderer?.node.place ?? .identity)
|
||||
}
|
||||
|
||||
class func absoluteTransform(_ nodeRenderer: NodeRenderer?, _ context: AnimationContext, pos: Transform) -> Transform {
|
||||
|
@ -23,26 +23,26 @@ open class Easing {
|
||||
public static let elasticInOut: Easing = ElasticInOut()
|
||||
|
||||
public static func elasticOut(elasticity: Double = 10.0) -> ElasticOut {
|
||||
return ElasticOut(elasticity: elasticity)
|
||||
ElasticOut(elasticity: elasticity)
|
||||
}
|
||||
public static func elasticInOut(elasticity: Double = 10.0) -> ElasticInOut {
|
||||
return ElasticInOut(elasticity: elasticity)
|
||||
ElasticInOut(elasticity: elasticity)
|
||||
}
|
||||
|
||||
open func progressFor(time: Double) -> Double {
|
||||
return time
|
||||
time
|
||||
}
|
||||
}
|
||||
|
||||
private class EaseIn: Easing {
|
||||
override open func progressFor(time t: Double) -> Double {
|
||||
return t * t
|
||||
t * t
|
||||
}
|
||||
}
|
||||
|
||||
private class EaseOut: Easing {
|
||||
override open func progressFor(time t: Double) -> Double {
|
||||
return -(t * (t - 2))
|
||||
-(t * (t - 2))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,19 +2,19 @@ import Foundation
|
||||
|
||||
// swiftlint:disable trailing_closure
|
||||
public func >> (a: Double, b: Double) -> OpacityAnimationDescription {
|
||||
return OpacityAnimationDescription(valueFunc: { t in
|
||||
OpacityAnimationDescription(valueFunc: { t in
|
||||
a.interpolate(b, progress: t)
|
||||
})
|
||||
}
|
||||
|
||||
public func >> (a: Transform, b: Transform) -> TransformAnimationDescription {
|
||||
return TransformAnimationDescription(valueFunc: { t in
|
||||
TransformAnimationDescription(valueFunc: { t in
|
||||
a.interpolate(b, progress: t)
|
||||
})
|
||||
}
|
||||
|
||||
public func >> (a: Locus, b: Locus) -> MorphingAnimationDescription {
|
||||
return MorphingAnimationDescription(valueFunc: { t in
|
||||
MorphingAnimationDescription(valueFunc: { t in
|
||||
// return a.interpolate(b, progress: t)
|
||||
if t == 0.0 {
|
||||
return a
|
||||
|
@ -4,6 +4,6 @@ public protocol ContentsInterpolation: Interpolable {
|
||||
|
||||
extension Array: ContentsInterpolation {
|
||||
public func interpolate(_ endValue: Array, progress: Double) -> Array {
|
||||
return self
|
||||
self
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,6 @@ public protocol DoubleInterpolation: Interpolable {
|
||||
|
||||
extension Double: DoubleInterpolation {
|
||||
public func interpolate(_ endValue: Double, progress: Double) -> Double {
|
||||
return self + (endValue - self) * progress
|
||||
self + (endValue - self) * progress
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ public protocol FillInterpolation: Interpolable {
|
||||
|
||||
extension Fill: FillInterpolation {
|
||||
public func interpolate(_ endValue: Fill, progress: Double) -> Self {
|
||||
return self
|
||||
self
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,6 @@ public protocol LocusInterpolation: Interpolable {
|
||||
|
||||
extension Locus: LocusInterpolation {
|
||||
public func interpolate(_ endValue: Locus, progress: Double) -> Self {
|
||||
return self
|
||||
self
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ public protocol ShapeInterpolation: Interpolable {
|
||||
|
||||
extension Shape: ShapeInterpolation {
|
||||
public func interpolate(_ endValue: Shape, progress: Double) -> Self {
|
||||
return self
|
||||
self
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ public protocol StrokeInterpolation: Interpolable {
|
||||
|
||||
extension Stroke: StrokeInterpolation {
|
||||
public func interpolate(_ endValue: Stroke, progress: Double) -> Self {
|
||||
return self
|
||||
self
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ public protocol TransformInterpolation: Interpolable {
|
||||
|
||||
extension Transform: TransformInterpolation {
|
||||
public func interpolate(_ endValue: Transform, progress: Double) -> Transform {
|
||||
return Transform(m11: self.m11.interpolate(endValue.m11, progress: progress),
|
||||
Transform(m11: self.m11.interpolate(endValue.m11, progress: progress),
|
||||
m12: self.m12.interpolate(endValue.m12, progress: progress),
|
||||
m21: self.m21.interpolate(endValue.m21, progress: progress),
|
||||
m22: self.m22.interpolate(endValue.m22, progress: progress),
|
||||
|
@ -3,7 +3,7 @@ import Foundation
|
||||
typealias Func2D = ((_ t: Double) -> (Point))
|
||||
|
||||
func BezierFunc2D(_ t: Double, p0: Point, p1: Point, p2: Point, p3: Point) -> Point {
|
||||
return Point(
|
||||
Point(
|
||||
x: polynom3(t, p0: p0.x, p1: p1.x, p2: p2.x, p3: p3.x),
|
||||
y: polynom3(t, p0: p0.y, p1: p1.y, p2: p2.y, p3: p3.y))
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ class MorphingAnimation: AnimationImpl<Locus> {
|
||||
|
||||
convenience init(animatedNode: Shape, startValue: Locus, finalValue: Locus, animationDuration: Double, delay: Double = 0.0, autostart: Bool = false, fps: UInt = 30) {
|
||||
|
||||
let interpolationFunc = { (t: Double) -> Locus in
|
||||
let interpolationFunc = { (_: Double) -> Locus in
|
||||
finalValue
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ public extension AnimatableVariable where T: LocusInterpolation {
|
||||
}
|
||||
|
||||
func animation(_ desc: MorphingAnimationDescription) -> Animation {
|
||||
return MorphingAnimation(animatedNode: node as! Shape, valueFunc: desc.valueFunc, animationDuration: desc.duration, delay: desc.delay, autostart: false)
|
||||
MorphingAnimation(animatedNode: node as! Shape, valueFunc: desc.valueFunc, animationDuration: desc.duration, delay: desc.delay, autostart: false)
|
||||
}
|
||||
|
||||
func animate(from: Locus? = nil, to: Locus, during: Double = 1.0, delay: Double = 0.0) {
|
||||
@ -68,7 +68,7 @@ public extension AnimatableVariable where T: LocusInterpolation {
|
||||
}
|
||||
|
||||
func animation(_ f: @escaping (Double) -> Locus, during: Double, delay: Double = 0.0) -> Animation {
|
||||
return MorphingAnimation(animatedNode: node as! Shape, valueFunc: f, animationDuration: during, delay: delay)
|
||||
MorphingAnimation(animatedNode: node as! Shape, valueFunc: f, animationDuration: during, delay: delay)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public extension AnimatableVariable where T: DoubleInterpolation {
|
||||
}
|
||||
|
||||
func animation(_ desc: OpacityAnimationDescription) -> Animation {
|
||||
return OpacityAnimation(animatedNode: node!, valueFunc: desc.valueFunc, animationDuration: desc.duration, delay: desc.delay, autostart: false)
|
||||
OpacityAnimation(animatedNode: node!, valueFunc: desc.valueFunc, animationDuration: desc.duration, delay: desc.delay, autostart: false)
|
||||
}
|
||||
|
||||
func animate(from: Double? = nil, to: Double, during: Double = 1.0, delay: Double = 0.0) {
|
||||
@ -72,7 +72,7 @@ public extension AnimatableVariable where T: DoubleInterpolation {
|
||||
}
|
||||
|
||||
func animation(_ f: @escaping ((Double) -> Double), during: Double = 1.0, delay: Double = 0.0) -> Animation {
|
||||
return OpacityAnimation(animatedNode: node!, valueFunc: f, animationDuration: during, delay: delay)
|
||||
OpacityAnimation(animatedNode: node!, valueFunc: f, animationDuration: during, delay: delay)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -51,11 +51,11 @@ public typealias PathAnimationDescription = AnimationDescription<Double>
|
||||
open class StrokeAnimatableVariable: AnimatableVariable<Stroke?> {
|
||||
|
||||
public var end: StrokeSideVariable {
|
||||
return StrokeSideVariable(parentVar: self, isEnd: true)
|
||||
StrokeSideVariable(parentVar: self, isEnd: true)
|
||||
}
|
||||
|
||||
public var start: StrokeSideVariable {
|
||||
return StrokeSideVariable(parentVar: self, isEnd: false)
|
||||
StrokeSideVariable(parentVar: self, isEnd: false)
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ open class StrokeSideVariable {
|
||||
}
|
||||
|
||||
public func animation(_ desc: PathAnimationDescription) -> Animation {
|
||||
return PathAnimation(animatedNode: node as! Shape, isEnd: isEnd, valueFunc: desc.valueFunc, animationDuration: desc.duration, delay: desc.delay, autostart: false)
|
||||
PathAnimation(animatedNode: node as! Shape, isEnd: isEnd, valueFunc: desc.valueFunc, animationDuration: desc.duration, delay: desc.delay, autostart: false)
|
||||
}
|
||||
|
||||
public func animate(from: Double? = nil, to: Double = 1, during: Double = 1.0, delay: Double = 0.0) {
|
||||
@ -92,13 +92,12 @@ open class StrokeSideVariable {
|
||||
return self.animation((safeFrom >> to).t(during, delay: delay))
|
||||
}
|
||||
let origin = Double(0)
|
||||
let factory = { () -> (Double) -> Double in
|
||||
{ (t: Double) in origin.interpolate(to, progress: t) }
|
||||
let factory = { () -> (Double) -> Double in { (t: Double) in origin.interpolate(to, progress: t) }
|
||||
}
|
||||
return PathAnimation(animatedNode: node as! Shape, isEnd: isEnd, factory: factory, animationDuration: during, delay: delay)
|
||||
}
|
||||
|
||||
public func animation(_ f: @escaping ((Double) -> Double), during: Double = 1.0, delay: Double = 0.0) -> Animation {
|
||||
return PathAnimation(animatedNode: node as! Shape, isEnd: isEnd, valueFunc: f, animationDuration: during, delay: delay)
|
||||
PathAnimation(animatedNode: node as! Shape, isEnd: isEnd, valueFunc: f, animationDuration: during, delay: delay)
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public extension AnimatableVariable where T: TransformInterpolation {
|
||||
}
|
||||
|
||||
func animation(_ desc: TransformAnimationDescription) -> Animation {
|
||||
return TransformAnimation(animatedNode: node!, valueFunc: desc.valueFunc, animationDuration: desc.duration, delay: desc.delay, autostart: false)
|
||||
TransformAnimation(animatedNode: node!, valueFunc: desc.valueFunc, animationDuration: desc.duration, delay: desc.delay, autostart: false)
|
||||
}
|
||||
|
||||
func animate(from: Transform? = nil, to: Transform, during: Double = 1.0, delay: Double = 0.0) {
|
||||
@ -99,7 +99,7 @@ public extension AnimatableVariable where T: TransformInterpolation {
|
||||
}
|
||||
|
||||
func animation(_ f: @escaping ((Double) -> Transform), during: Double = 1.0, delay: Double = 0.0) -> Animation {
|
||||
return TransformAnimation(animatedNode: node!, valueFunc: f, animationDuration: during, delay: delay)
|
||||
TransformAnimation(animatedNode: node!, valueFunc: f, animationDuration: during, delay: delay)
|
||||
}
|
||||
|
||||
func animation(angle: Double, x: Double? = .none, y: Double? = .none, during: Double = 1.0, delay: Double = 0.0) -> Animation {
|
||||
@ -128,7 +128,7 @@ public extension AnimatableVariable where T: TransformInterpolation {
|
||||
|
||||
func animation(along path: Path, during: Double = 1.0, delay: Double = 0.0) -> Animation {
|
||||
|
||||
let factory = { () -> (Double) -> Transform in { (t: Double) in self.node?.place ?? .identity }
|
||||
let factory = { () -> (Double) -> Transform in { (_: Double) in self.node?.place ?? .identity }
|
||||
}
|
||||
return TransformAnimation(animatedNode: self.node!, factory: factory, along: path, animationDuration: during, delay: delay)
|
||||
}
|
||||
|
@ -160,18 +160,18 @@ class AnimationUtils {
|
||||
extension Node {
|
||||
|
||||
func isAnimating() -> Bool {
|
||||
return !animations.filter { $0.state() == AnimationState.running }.isEmpty
|
||||
!animations.filter { $0.state() == AnimationState.running }.isEmpty
|
||||
}
|
||||
|
||||
func needsLayer() -> Bool {
|
||||
return !animations.filter { $0.state() == AnimationState.running || $0.state() == AnimationState.initial }.isEmpty
|
||||
!animations.filter { $0.state() == AnimationState.running || $0.state() == AnimationState.initial }.isEmpty
|
||||
}
|
||||
}
|
||||
|
||||
extension NodeRenderer {
|
||||
|
||||
func isAnimating() -> Bool {
|
||||
return layer != nil
|
||||
layer != nil
|
||||
}
|
||||
|
||||
func freeLayer() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
// TODO: Implement better hash
|
||||
|
||||
public func == (lhs: Node, rhs: Node) -> Bool {
|
||||
return lhs === rhs
|
||||
lhs === rhs
|
||||
}
|
||||
|
||||
extension NodeRenderer: Hashable {
|
||||
@ -11,5 +11,5 @@ extension NodeRenderer: Hashable {
|
||||
}
|
||||
|
||||
func == (lhs: NodeRenderer, rhs: NodeRenderer) -> Bool {
|
||||
return lhs === rhs
|
||||
lhs === rhs
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ extension Transform: Hashable {
|
||||
}
|
||||
|
||||
public func == (lhs: Transform, rhs: Transform) -> Bool {
|
||||
return lhs.m11 == rhs.m11 &&
|
||||
lhs.m11 == rhs.m11 &&
|
||||
lhs.m12 == rhs.m12 &&
|
||||
lhs.m21 == rhs.m21 &&
|
||||
lhs.m22 == rhs.m22 &&
|
||||
|
@ -39,7 +39,7 @@ func addPathAnimation(_ animation: BasicAnimation, _ context: AnimationContext,
|
||||
animation.onProgressUpdate?(t)
|
||||
}
|
||||
|
||||
generatedAnim.completion = { finished in
|
||||
generatedAnim.completion = { _ in
|
||||
|
||||
animation.progress = animation.manualStop ? 0.0 : 1.0
|
||||
|
||||
|
@ -16,7 +16,7 @@ class ChangeHandler<T>: Equatable {
|
||||
}
|
||||
|
||||
static func == (lhs: ChangeHandler<T>, rhs: ChangeHandler<T>) -> Bool {
|
||||
return lhs === rhs
|
||||
lhs === rhs
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ class NodePath {
|
||||
public struct TouchPoint {
|
||||
public let id: Int
|
||||
@available(*, deprecated) public var location: Point // absolute location
|
||||
{ return absoluteLocation }
|
||||
{ absoluteLocation }
|
||||
|
||||
private let absoluteLocation: Point
|
||||
private let relativeLocation: Point // location inside the node
|
||||
|
@ -17,7 +17,7 @@ open class ContentLayout {
|
||||
public static let none: ContentLayout = NoneLayout()
|
||||
|
||||
public static func of(scaling: AspectRatio = .meet, xAlign: Align = .mid, yAlign: Align = .mid) -> ContentLayout {
|
||||
return ScalingContentLayout(scaling: scaling, xAlign: xAlign, yAlign: yAlign)
|
||||
ScalingContentLayout(scaling: scaling, xAlign: xAlign, yAlign: yAlign)
|
||||
}
|
||||
|
||||
public static func of(contentMode: MViewContentMode) -> ContentLayout {
|
||||
@ -57,11 +57,11 @@ open class ContentLayout {
|
||||
}
|
||||
|
||||
open func layout(size: Size, into sizeToFitIn: Size) -> Transform {
|
||||
return layout(rect: size.rect(), into: sizeToFitIn)
|
||||
layout(rect: size.rect(), into: sizeToFitIn)
|
||||
}
|
||||
|
||||
open func layout(rect: Rect, into sizeToFitIn: Size) -> Transform {
|
||||
return Transform.identity
|
||||
Transform.identity
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ open class Align {
|
||||
public static let max: Align = MaxAlign()
|
||||
|
||||
open func align(outer: Double, inner: Double) -> Double {
|
||||
return 0
|
||||
0
|
||||
}
|
||||
|
||||
open func align(size: Double) -> Double {
|
||||
return align(outer: size, inner: 0)
|
||||
align(outer: size, inner: 0)
|
||||
}
|
||||
|
||||
}
|
||||
@ -17,13 +17,13 @@ open class Align {
|
||||
private class MidAlign: Align {
|
||||
|
||||
override func align(outer: Double, inner: Double) -> Double {
|
||||
return (outer - inner) / 2
|
||||
(outer - inner) / 2
|
||||
}
|
||||
}
|
||||
|
||||
private class MaxAlign: Align {
|
||||
|
||||
override func align(outer: Double, inner: Double) -> Double {
|
||||
return outer - inner
|
||||
outer - inner
|
||||
}
|
||||
}
|
||||
|
@ -6,15 +6,15 @@ open class AspectRatio {
|
||||
internal static let doNothing: AspectRatio = DoNothingAspectRatio()
|
||||
|
||||
open func fit(size: Size, into sizeToFitIn: Size) -> Size {
|
||||
return Size(w: sizeToFitIn.w, h: sizeToFitIn.h)
|
||||
Size(w: sizeToFitIn.w, h: sizeToFitIn.h)
|
||||
}
|
||||
|
||||
open func fit(rect: Rect, into rectToFitIn: Rect) -> Size {
|
||||
return fit(size: rect.size(), into: rectToFitIn.size())
|
||||
fit(size: rect.size(), into: rectToFitIn.size())
|
||||
}
|
||||
|
||||
open func fit(size: Size, into rectToFitIn: Rect) -> Size {
|
||||
return fit(size: size, into: rectToFitIn.size())
|
||||
fit(size: size, into: rectToFitIn.size())
|
||||
}
|
||||
|
||||
}
|
||||
@ -22,7 +22,7 @@ open class AspectRatio {
|
||||
internal class DoNothingAspectRatio: AspectRatio {
|
||||
|
||||
override func fit(size: Size, into sizeToFitIn: Size) -> Size {
|
||||
return size
|
||||
size
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,23 +155,23 @@ open class Color: Fill {
|
||||
}
|
||||
|
||||
open func r() -> Int {
|
||||
return ( ( val >> 16 ) & 0xff )
|
||||
( ( val >> 16 ) & 0xff )
|
||||
}
|
||||
|
||||
open func g() -> Int {
|
||||
return ( ( val >> 8 ) & 0xff )
|
||||
( ( val >> 8 ) & 0xff )
|
||||
}
|
||||
|
||||
open func b() -> Int {
|
||||
return ( val & 0xff )
|
||||
( val & 0xff )
|
||||
}
|
||||
|
||||
open func a() -> Int {
|
||||
return ( 255 - ( ( val >> 24 ) & 0xff ) )
|
||||
( 255 - ( ( val >> 24 ) & 0xff ) )
|
||||
}
|
||||
|
||||
public func with(a: Double) -> Color {
|
||||
return Color.rgba(r: r(), g: g(), b: b(), a: a)
|
||||
Color.rgba(r: r(), g: g(), b: b(), a: a)
|
||||
}
|
||||
|
||||
open class func rgbt(r: Int, g: Int, b: Int, t: Int) -> Color {
|
||||
@ -183,11 +183,11 @@ open class Color: Fill {
|
||||
}
|
||||
|
||||
open class func rgba(r: Int, g: Int, b: Int, a: Double) -> Color {
|
||||
return rgbt( r: r, g: g, b: b, t: Int( ( ( 1 - a ) * 255 ) ) )
|
||||
rgbt( r: r, g: g, b: b, t: Int( ( ( 1 - a ) * 255 ) ) )
|
||||
}
|
||||
|
||||
open class func rgb(r: Int, g: Int, b: Int) -> Color {
|
||||
return rgbt( r: r, g: g, b: b, t: 0 )
|
||||
rgbt( r: r, g: g, b: b, t: 0 )
|
||||
}
|
||||
|
||||
override func equals<T>(other: T) -> Bool where T: Fill {
|
||||
|
@ -7,26 +7,26 @@ open class Effect {
|
||||
}
|
||||
|
||||
public static func dropShadow(dx: Double = 0, dy: Double = -3, r: Double = 3, color: Color = .black) -> Effect? {
|
||||
return OffsetEffect(dx: dx, dy: dy).setColor(to: color).blur(r: r).blend()
|
||||
OffsetEffect(dx: dx, dy: dy).setColor(to: color).blur(r: r).blend()
|
||||
}
|
||||
|
||||
public func offset(dx: Double, dy: Double) -> Effect {
|
||||
return OffsetEffect(dx: dx, dy: dy, input: self)
|
||||
OffsetEffect(dx: dx, dy: dy, input: self)
|
||||
}
|
||||
|
||||
public func mapColor(with matrix: ColorMatrix) -> Effect {
|
||||
return ColorMatrixEffect(matrix: matrix, input: self)
|
||||
ColorMatrixEffect(matrix: matrix, input: self)
|
||||
}
|
||||
|
||||
public func setColor(to color: Color) -> Effect {
|
||||
return ColorMatrixEffect(matrix: ColorMatrix(color: color), input: self)
|
||||
ColorMatrixEffect(matrix: ColorMatrix(color: color), input: self)
|
||||
}
|
||||
|
||||
public func blur(r: Double) -> Effect {
|
||||
return GaussianBlur(r: r, input: self)
|
||||
GaussianBlur(r: r, input: self)
|
||||
}
|
||||
|
||||
public func blend() -> Effect {
|
||||
return BlendEffect(input: self)
|
||||
BlendEffect(input: self)
|
||||
}
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ open class Fill: Equatable {
|
||||
}
|
||||
|
||||
public func ==<T> (lhs: T, rhs: T) -> Bool where T: Fill {
|
||||
return lhs.equals(other: rhs)
|
||||
lhs.equals(other: rhs)
|
||||
}
|
||||
|
@ -10,5 +10,5 @@ open class Stop: Equatable {
|
||||
}
|
||||
|
||||
public func == (lhs: Stop, rhs: Stop) -> Bool {
|
||||
return lhs.offset == rhs.offset && lhs.color == rhs.color
|
||||
lhs.offset == rhs.offset && lhs.color == rhs.color
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ open class Stroke: Equatable {
|
||||
}
|
||||
|
||||
public func ==<T> (lhs: T, rhs: T) -> Bool where T: Stroke {
|
||||
return lhs.fill == rhs.fill
|
||||
lhs.fill == rhs.fill
|
||||
&& lhs.width == rhs.width
|
||||
&& lhs.cap == rhs.cap
|
||||
&& lhs.join == rhs.join
|
||||
|
@ -13,7 +13,7 @@ open class Arc: Locus {
|
||||
}
|
||||
|
||||
override open func bounds() -> Rect {
|
||||
return Rect(
|
||||
Rect(
|
||||
x: ellipse.cx - ellipse.rx,
|
||||
y: ellipse.cy - ellipse.ry,
|
||||
w: ellipse.rx * 2.0,
|
||||
|
@ -11,7 +11,7 @@ open class Circle: Locus {
|
||||
}
|
||||
|
||||
override open func bounds() -> Rect {
|
||||
return Rect(
|
||||
Rect(
|
||||
x: cx - r,
|
||||
y: cy - r,
|
||||
w: r * 2.0,
|
||||
@ -19,11 +19,11 @@ open class Circle: Locus {
|
||||
}
|
||||
|
||||
open func arc(shift: Double, extent: Double) -> Arc {
|
||||
return Arc(ellipse: Ellipse(cx: cx, cy: cy, rx: r, ry: r), shift: shift, extent: extent)
|
||||
Arc(ellipse: Ellipse(cx: cx, cy: cy, rx: r, ry: r), shift: shift, extent: extent)
|
||||
}
|
||||
|
||||
override open func toPath() -> Path {
|
||||
return MoveTo(x: cx, y: cy).m(-r, 0).a(r, r, 0.0, true, false, r * 2.0, 0.0).a(r, r, 0.0, true, false, -(r * 2.0), 0.0).build()
|
||||
MoveTo(x: cx, y: cy).m(-r, 0).a(r, r, 0.0, true, false, r * 2.0, 0.0).a(r, r, 0.0, true, false, -(r * 2.0), 0.0).build()
|
||||
}
|
||||
|
||||
override func equals<T>(other: T) -> Bool where T: Locus {
|
||||
|
@ -13,7 +13,7 @@ open class Ellipse: Locus {
|
||||
}
|
||||
|
||||
override open func bounds() -> Rect {
|
||||
return Rect(
|
||||
Rect(
|
||||
x: cx - rx,
|
||||
y: cy - ry,
|
||||
w: rx * 2.0,
|
||||
@ -21,7 +21,7 @@ open class Ellipse: Locus {
|
||||
}
|
||||
|
||||
open func arc(shift: Double, extent: Double) -> Arc {
|
||||
return Arc(ellipse: self, shift: shift, extent: extent)
|
||||
Arc(ellipse: self, shift: shift, extent: extent)
|
||||
}
|
||||
|
||||
override func equals<T>(other: T) -> Bool where T: Locus {
|
||||
|
@ -5,7 +5,7 @@ open class GeomUtils {
|
||||
|
||||
@available(*, deprecated)
|
||||
open class func concat(t1: Transform, t2: Transform) -> Transform {
|
||||
return t1.concat(with: t2)
|
||||
t1.concat(with: t2)
|
||||
}
|
||||
|
||||
open class func centerRotation(node: Node, place: Transform, angle: Double) -> Transform {
|
||||
|
@ -20,11 +20,11 @@ open class Line: Locus {
|
||||
}
|
||||
|
||||
override open func bounds() -> Rect {
|
||||
return Rect(x: min(x1, x2), y: min(y1, y2), w: abs(x1 - x2), h: abs(y1 - y2))
|
||||
Rect(x: min(x1, x2), y: min(y1, y2), w: abs(x1 - x2), h: abs(y1 - y2))
|
||||
}
|
||||
|
||||
override open func toPath() -> Path {
|
||||
return MoveTo(x: x1, y: y1).lineTo(x: x2, y: y2).build()
|
||||
MoveTo(x: x1, y: y1).lineTo(x: x2, y: y2).build()
|
||||
}
|
||||
|
||||
override func equals<T>(other: T) -> Bool where T: Locus {
|
||||
|
@ -4,35 +4,35 @@ open class Locus: Equatable {
|
||||
}
|
||||
|
||||
open func bounds() -> Rect {
|
||||
return Rect()
|
||||
Rect()
|
||||
}
|
||||
|
||||
open func stroke(with: Stroke) -> Shape {
|
||||
return Shape(form: self, stroke: with)
|
||||
Shape(form: self, stroke: with)
|
||||
}
|
||||
|
||||
open func fill(with: Fill) -> Shape {
|
||||
return Shape(form: self, fill: with)
|
||||
Shape(form: self, fill: with)
|
||||
}
|
||||
|
||||
open func fill(_ hex: Int) -> Shape {
|
||||
return Shape(form: self, fill: Color(val: hex))
|
||||
Shape(form: self, fill: Color(val: hex))
|
||||
}
|
||||
|
||||
open func fill(_ fill: Fill) -> Shape {
|
||||
return Shape(form: self, fill: fill)
|
||||
Shape(form: self, fill: fill)
|
||||
}
|
||||
|
||||
open func stroke(fill: Fill = Color.black, width: Double = 1, cap: LineCap = .butt, join: LineJoin = .miter, dashes: [Double] = []) -> Shape {
|
||||
return Shape(form: self, stroke: Stroke(fill: fill, width: width, cap: cap, join: join, dashes: dashes))
|
||||
Shape(form: self, stroke: Stroke(fill: fill, width: width, cap: cap, join: join, dashes: dashes))
|
||||
}
|
||||
|
||||
open func stroke(color: Color, width: Double = 1, cap: LineCap = .butt, join: LineJoin = .miter, dashes: [Double] = []) -> Shape {
|
||||
return Shape(form: self, stroke: Stroke(fill: color, width: width, cap: cap, join: join, dashes: dashes))
|
||||
Shape(form: self, stroke: Stroke(fill: color, width: width, cap: cap, join: join, dashes: dashes))
|
||||
}
|
||||
|
||||
open func stroke(color: Int, width: Double = 1, cap: LineCap = .butt, join: LineJoin = .miter, dashes: [Double] = []) -> Shape {
|
||||
return Shape(form: self, stroke: Stroke(fill: Color(color), width: width, cap: cap, join: join, dashes: dashes))
|
||||
Shape(form: self, stroke: Stroke(fill: Color(color), width: width, cap: cap, join: join, dashes: dashes))
|
||||
}
|
||||
|
||||
open func toPath() -> Path {
|
||||
@ -45,6 +45,6 @@ open class Locus: Equatable {
|
||||
}
|
||||
|
||||
public func ==<T> (lhs: T, rhs: T) -> Bool where T: Locus {
|
||||
return type(of: lhs) == type(of: rhs)
|
||||
type(of: lhs) == type(of: rhs)
|
||||
&& lhs.equals(other: rhs)
|
||||
}
|
||||
|
@ -13,11 +13,11 @@ open class Path: Locus {
|
||||
}
|
||||
|
||||
override open func bounds() -> Rect {
|
||||
return toCGPath().boundingBoxOfPath.toMacaw()
|
||||
toCGPath().boundingBoxOfPath.toMacaw()
|
||||
}
|
||||
|
||||
override open func toPath() -> Path {
|
||||
return self
|
||||
self
|
||||
}
|
||||
|
||||
override func equals<T>(other: T) -> Bool where T: Locus {
|
||||
|
@ -9,111 +9,111 @@ open class PathBuilder {
|
||||
}
|
||||
|
||||
open func moveTo(x: Double, y: Double) -> PathBuilder {
|
||||
return M(x, y)
|
||||
M(x, y)
|
||||
}
|
||||
|
||||
open func lineTo(x: Double, y: Double) -> PathBuilder {
|
||||
return L(x, y)
|
||||
L(x, y)
|
||||
}
|
||||
|
||||
open func cubicTo(x1: Double, y1: Double, x2: Double, y2: Double, x: Double, y: Double) -> PathBuilder {
|
||||
return C(x1, y1, x2, y2, x, y)
|
||||
C(x1, y1, x2, y2, x, y)
|
||||
}
|
||||
|
||||
open func quadraticTo(x1: Double, y1: Double, x: Double, y: Double) -> PathBuilder {
|
||||
return Q(x1, y1, x, y)
|
||||
Q(x1, y1, x, y)
|
||||
}
|
||||
|
||||
open func arcTo(rx: Double, ry: Double, angle: Double, largeArc: Bool, sweep: Bool, x: Double, y: Double) -> PathBuilder {
|
||||
return A(rx, ry, angle, largeArc, sweep, x, y)
|
||||
A(rx, ry, angle, largeArc, sweep, x, y)
|
||||
}
|
||||
|
||||
open func close() -> PathBuilder {
|
||||
return Z()
|
||||
Z()
|
||||
}
|
||||
|
||||
open func m(_ x: Double, _ y: Double) -> PathBuilder {
|
||||
return PathBuilder(segment: PathSegment(type: .m, data: [x, y]), rest: self)
|
||||
PathBuilder(segment: PathSegment(type: .m, data: [x, y]), rest: self)
|
||||
}
|
||||
|
||||
open func M(_ x: Double, _ y: Double) -> PathBuilder {
|
||||
return PathBuilder(segment: PathSegment(type: .M, data: [x, y]), rest: self)
|
||||
PathBuilder(segment: PathSegment(type: .M, data: [x, y]), rest: self)
|
||||
}
|
||||
|
||||
open func l(_ x: Double, _ y: Double) -> PathBuilder {
|
||||
return PathBuilder(segment: PathSegment(type: .l, data: [x, y]), rest: self)
|
||||
PathBuilder(segment: PathSegment(type: .l, data: [x, y]), rest: self)
|
||||
}
|
||||
|
||||
open func L(_ x: Double, _ y: Double) -> PathBuilder {
|
||||
return PathBuilder(segment: PathSegment(type: .L, data: [x, y]), rest: self)
|
||||
PathBuilder(segment: PathSegment(type: .L, data: [x, y]), rest: self)
|
||||
}
|
||||
|
||||
open func h(_ x: Double) -> PathBuilder {
|
||||
return PathBuilder(segment: PathSegment(type: .h, data: [x]), rest: self)
|
||||
PathBuilder(segment: PathSegment(type: .h, data: [x]), rest: self)
|
||||
}
|
||||
|
||||
open func H(_ x: Double) -> PathBuilder {
|
||||
return PathBuilder(segment: PathSegment(type: .H, data: [x]), rest: self)
|
||||
PathBuilder(segment: PathSegment(type: .H, data: [x]), rest: self)
|
||||
}
|
||||
|
||||
open func v(_ y: Double) -> PathBuilder {
|
||||
return PathBuilder(segment: PathSegment(type: .v, data: [y]), rest: self)
|
||||
PathBuilder(segment: PathSegment(type: .v, data: [y]), rest: self)
|
||||
}
|
||||
|
||||
open func V(_ y: Double) -> PathBuilder {
|
||||
return PathBuilder(segment: PathSegment(type: .V, data: [y]), rest: self)
|
||||
PathBuilder(segment: PathSegment(type: .V, data: [y]), rest: self)
|
||||
}
|
||||
|
||||
open func c(_ x1: Double, _ y1: Double, _ x2: Double, _ y2: Double, _ x: Double, _ y: Double) -> PathBuilder {
|
||||
return PathBuilder(segment: PathSegment(type: .c, data: [x1, y1, x2, y2, x, y]), rest: self)
|
||||
PathBuilder(segment: PathSegment(type: .c, data: [x1, y1, x2, y2, x, y]), rest: self)
|
||||
}
|
||||
|
||||
open func C(_ x1: Double, _ y1: Double, _ x2: Double, _ y2: Double, _ x: Double, _ y: Double) -> PathBuilder {
|
||||
return PathBuilder(segment: PathSegment(type: .C, data: [x1, y1, x2, y2, x, y]), rest: self)
|
||||
PathBuilder(segment: PathSegment(type: .C, data: [x1, y1, x2, y2, x, y]), rest: self)
|
||||
}
|
||||
|
||||
open func s(_ x2: Double, _ y2: Double, _ x: Double, _ y: Double) -> PathBuilder {
|
||||
return PathBuilder(segment: PathSegment(type: .s, data: [x2, y2, x, y]), rest: self)
|
||||
PathBuilder(segment: PathSegment(type: .s, data: [x2, y2, x, y]), rest: self)
|
||||
}
|
||||
|
||||
open func S(_ x2: Double, _ y2: Double, _ x: Double, _ y: Double) -> PathBuilder {
|
||||
return PathBuilder(segment: PathSegment(type: .S, data: [x2, y2, x, y]), rest: self)
|
||||
PathBuilder(segment: PathSegment(type: .S, data: [x2, y2, x, y]), rest: self)
|
||||
}
|
||||
|
||||
open func q(_ x1: Double, _ y1: Double, _ x: Double, _ y: Double) -> PathBuilder {
|
||||
return PathBuilder(segment: PathSegment(type: .q, data: [x1, y1, x, y]), rest: self)
|
||||
PathBuilder(segment: PathSegment(type: .q, data: [x1, y1, x, y]), rest: self)
|
||||
}
|
||||
|
||||
open func Q(_ x1: Double, _ y1: Double, _ x: Double, _ y: Double) -> PathBuilder {
|
||||
return PathBuilder(segment: PathSegment(type: .Q, data: [x1, y1, x, y]), rest: self)
|
||||
PathBuilder(segment: PathSegment(type: .Q, data: [x1, y1, x, y]), rest: self)
|
||||
}
|
||||
|
||||
open func t(_ x: Double, _ y: Double) -> PathBuilder {
|
||||
return PathBuilder(segment: PathSegment(type: .t, data: [x, y]), rest: self)
|
||||
PathBuilder(segment: PathSegment(type: .t, data: [x, y]), rest: self)
|
||||
}
|
||||
|
||||
open func T(_ x: Double, _ y: Double) -> PathBuilder {
|
||||
return PathBuilder(segment: PathSegment(type: .T, data: [x, y]), rest: self)
|
||||
PathBuilder(segment: PathSegment(type: .T, data: [x, y]), rest: self)
|
||||
}
|
||||
|
||||
open func a(_ rx: Double, _ ry: Double, _ angle: Double, _ largeArc: Bool, _ sweep: Bool, _ x: Double, _ y: Double) -> PathBuilder {
|
||||
return PathBuilder(segment: PathSegment(type: .a, data: [rx, ry, angle, boolToNum(largeArc), boolToNum(sweep), x, y]), rest: self)
|
||||
PathBuilder(segment: PathSegment(type: .a, data: [rx, ry, angle, boolToNum(largeArc), boolToNum(sweep), x, y]), rest: self)
|
||||
}
|
||||
|
||||
open func A(_ rx: Double, _ ry: Double, _ angle: Double, _ largeArc: Bool, _ sweep: Bool, _ x: Double, _ y: Double) -> PathBuilder {
|
||||
return PathBuilder(segment: PathSegment(type: .A, data: [rx, ry, angle, boolToNum(largeArc), boolToNum(sweep), x, y]), rest: self)
|
||||
PathBuilder(segment: PathSegment(type: .A, data: [rx, ry, angle, boolToNum(largeArc), boolToNum(sweep), x, y]), rest: self)
|
||||
}
|
||||
|
||||
open func e(_ x: Double, _ y: Double, _ w: Double, _ h: Double, _ startAngle: Double, _ arcAngle: Double) -> PathBuilder {
|
||||
return PathBuilder(segment: PathSegment(type: .e, data: [x, y, w, h, startAngle, arcAngle]), rest: self)
|
||||
PathBuilder(segment: PathSegment(type: .e, data: [x, y, w, h, startAngle, arcAngle]), rest: self)
|
||||
}
|
||||
|
||||
open func E(_ x: Double, _ y: Double, _ w: Double, _ h: Double, _ startAngle: Double, _ arcAngle: Double) -> PathBuilder {
|
||||
return PathBuilder(segment: PathSegment(type: .E, data: [x, y, w, h, startAngle, arcAngle]), rest: self)
|
||||
PathBuilder(segment: PathSegment(type: .E, data: [x, y, w, h, startAngle, arcAngle]), rest: self)
|
||||
}
|
||||
|
||||
open func Z() -> PathBuilder {
|
||||
return PathBuilder(segment: PathSegment(type: .z), rest: self)
|
||||
PathBuilder(segment: PathSegment(type: .z), rest: self)
|
||||
}
|
||||
|
||||
open func build() -> Path {
|
||||
@ -127,7 +127,7 @@ open class PathBuilder {
|
||||
}
|
||||
|
||||
fileprivate func boolToNum(_ value: Bool) -> Double {
|
||||
return value ? 1 : 0
|
||||
value ? 1 : 0
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ open class PathSegment: Equatable {
|
||||
}
|
||||
|
||||
public static func == (lhs: PathSegment, rhs: PathSegment) -> Bool {
|
||||
return lhs.type == rhs.type
|
||||
lhs.type == rhs.type
|
||||
&& lhs.data == rhs.data
|
||||
}
|
||||
}
|
||||
|
@ -18,15 +18,15 @@ open class Point: Locus {
|
||||
}
|
||||
|
||||
override open func bounds() -> Rect {
|
||||
return Rect(x: x, y: y, w: 0.0, h: 0.0)
|
||||
Rect(x: x, y: y, w: 0.0, h: 0.0)
|
||||
}
|
||||
|
||||
open func add(_ point: Point) -> Point {
|
||||
return Point( x: x + point.x, y: y + point.y)
|
||||
Point( x: x + point.x, y: y + point.y)
|
||||
}
|
||||
|
||||
open func rect(size: Size) -> Rect {
|
||||
return Rect(point: self, size: size)
|
||||
Rect(point: self, size: size)
|
||||
}
|
||||
|
||||
open func distance(to point: Point) -> Double {
|
||||
@ -36,7 +36,7 @@ open class Point: Locus {
|
||||
}
|
||||
|
||||
override open func toPath() -> Path {
|
||||
return MoveTo(x: x, y: y).lineTo(x: x, y: y).build()
|
||||
MoveTo(x: x, y: y).lineTo(x: x, y: y).build()
|
||||
}
|
||||
|
||||
override func equals<T>(other: T) -> Bool where T: Locus {
|
||||
@ -51,6 +51,6 @@ open class Point: Locus {
|
||||
extension Point {
|
||||
|
||||
public static func - (lhs: Point, rhs: Point) -> Size {
|
||||
return Size(w: lhs.x - rhs.x, h: lhs.y - rhs.y)
|
||||
Size(w: lhs.x - rhs.x, h: lhs.y - rhs.y)
|
||||
}
|
||||
}
|
||||
|
@ -27,31 +27,31 @@ open class Rect: Locus {
|
||||
}
|
||||
|
||||
override open func bounds() -> Rect {
|
||||
return self
|
||||
self
|
||||
}
|
||||
|
||||
open func round(rx: Double, ry: Double) -> RoundRect {
|
||||
return RoundRect(rect: self, rx: rx, ry: ry)
|
||||
RoundRect(rect: self, rx: rx, ry: ry)
|
||||
}
|
||||
|
||||
public func round(r: Double) -> RoundRect {
|
||||
return RoundRect(rect: self, rx: r, ry: r)
|
||||
RoundRect(rect: self, rx: r, ry: r)
|
||||
}
|
||||
|
||||
open func center() -> Point {
|
||||
return Point(x: x + w / 2, y: y + h / 2)
|
||||
Point(x: x + w / 2, y: y + h / 2)
|
||||
}
|
||||
|
||||
open func contains(locus: Locus) -> Bool {
|
||||
return false
|
||||
false
|
||||
}
|
||||
|
||||
class func zero() -> Rect {
|
||||
return Rect(x: 0.0, y: 0.0, w: 0.0, h: 0.0)
|
||||
Rect(x: 0.0, y: 0.0, w: 0.0, h: 0.0)
|
||||
}
|
||||
|
||||
open func move(offset: Point) -> Rect {
|
||||
return Rect(
|
||||
Rect(
|
||||
x: self.x + offset.x,
|
||||
y: self.y + offset.y,
|
||||
w: self.w,
|
||||
@ -59,7 +59,7 @@ open class Rect: Locus {
|
||||
}
|
||||
|
||||
open func union(rect: Rect) -> Rect {
|
||||
return Rect(
|
||||
Rect(
|
||||
x: min(self.x, rect.x),
|
||||
y: min(self.y, rect.y),
|
||||
w: max(self.x + self.w, rect.x + rect.w) - min(self.x, rect.x),
|
||||
@ -67,11 +67,11 @@ open class Rect: Locus {
|
||||
}
|
||||
|
||||
open func size() -> Size {
|
||||
return Size(w: w, h: h)
|
||||
Size(w: w, h: h)
|
||||
}
|
||||
|
||||
override open func toPath() -> Path {
|
||||
return MoveTo(x: x, y: y).lineTo(x: x, y: y + h).lineTo(x: x + w, y: y + h).lineTo(x: x + w, y: y).close().build()
|
||||
MoveTo(x: x, y: y).lineTo(x: x, y: y + h).lineTo(x: x + w, y: y + h).lineTo(x: x + w, y: y).close().build()
|
||||
}
|
||||
|
||||
override func equals<T>(other: T) -> Bool where T: Locus {
|
||||
|
@ -11,7 +11,7 @@ open class RoundRect: Locus {
|
||||
}
|
||||
|
||||
override open func bounds() -> Rect {
|
||||
return rect
|
||||
rect
|
||||
}
|
||||
|
||||
override func equals<T>(other: T) -> Bool where T: Locus {
|
||||
|
@ -18,11 +18,11 @@ open class Size {
|
||||
}
|
||||
|
||||
open func rect(at point: Point = Point.origin) -> Rect {
|
||||
return Rect(point: point, size: self)
|
||||
Rect(point: point, size: self)
|
||||
}
|
||||
|
||||
open func angle() -> Double {
|
||||
return atan2(h, w)
|
||||
atan2(h, w)
|
||||
}
|
||||
|
||||
}
|
||||
@ -30,15 +30,15 @@ open class Size {
|
||||
extension Size {
|
||||
|
||||
public static func == (lhs: Size, rhs: Size) -> Bool {
|
||||
return lhs.w == rhs.w && lhs.h == rhs.h
|
||||
lhs.w == rhs.w && lhs.h == rhs.h
|
||||
}
|
||||
|
||||
public static func + (lhs: Size, rhs: Size) -> Size {
|
||||
return Size(w: lhs.w + rhs.w, h: lhs.h + rhs.h)
|
||||
Size(w: lhs.w + rhs.w, h: lhs.h + rhs.h)
|
||||
}
|
||||
|
||||
public static func - (lhs: Size, rhs: Size) -> Size {
|
||||
return Size(w: lhs.w - rhs.w, h: lhs.h - rhs.h)
|
||||
Size(w: lhs.w - rhs.w, h: lhs.h - rhs.h)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,30 +30,30 @@ public final class Transform {
|
||||
}
|
||||
|
||||
public func move(_ dx: Double, _ dy: Double) -> Transform {
|
||||
return move(dx: dx, dy: dy)
|
||||
move(dx: dx, dy: dy)
|
||||
}
|
||||
|
||||
public func move(dx: Double = 0, dy: Double = 0) -> Transform {
|
||||
return Transform(m11: m11, m12: m12, m21: m21, m22: m22,
|
||||
Transform(m11: m11, m12: m12, m21: m21, m22: m22,
|
||||
dx: dx * m11 + dy * m21 + self.dx,
|
||||
dy: dx * m12 + dy * m22 + self.dy)
|
||||
}
|
||||
|
||||
public func scale(sx: Double = 0, sy: Double = 0) -> Transform {
|
||||
return Transform(m11: m11 * sx, m12: m12 * sx, m21: m21 * sy, m22: m22 * sy, dx: dx, dy: dy)
|
||||
Transform(m11: m11 * sx, m12: m12 * sx, m21: m21 * sy, m22: m22 * sy, dx: dx, dy: dy)
|
||||
}
|
||||
|
||||
public func scale(_ sx: Double, _ sy: Double) -> Transform {
|
||||
return scale(sx: sx, sy: sy)
|
||||
scale(sx: sx, sy: sy)
|
||||
}
|
||||
|
||||
public func shear(shx: Double = 0, shy: Double = 0) -> Transform {
|
||||
return Transform(m11: m11 + m21 * shy, m12: m12 + m22 * shy,
|
||||
Transform(m11: m11 + m21 * shy, m12: m12 + m22 * shy,
|
||||
m21: m11 * shx + m21, m22: m12 * shx + m22, dx: dx, dy: dy)
|
||||
}
|
||||
|
||||
public func shear(_ shx: Double, _ shy: Double) -> Transform {
|
||||
return shear(shx: shx, shy: shy)
|
||||
shear(shx: shx, shy: shy)
|
||||
}
|
||||
|
||||
public func rotate(angle: Double) -> Transform {
|
||||
@ -65,39 +65,39 @@ public final class Transform {
|
||||
}
|
||||
|
||||
public func rotate(_ angle: Double) -> Transform {
|
||||
return rotate(angle: angle)
|
||||
rotate(angle: angle)
|
||||
}
|
||||
|
||||
public func rotate(angle: Double, x: Double = 0, y: Double = 0) -> Transform {
|
||||
return move(dx: x, dy: y).rotate(angle: angle).move(dx: -x, dy: -y)
|
||||
move(dx: x, dy: y).rotate(angle: angle).move(dx: -x, dy: -y)
|
||||
}
|
||||
|
||||
public func rotate(_ angle: Double, _ x: Double, _ y: Double) -> Transform {
|
||||
return rotate(angle: angle, x: x, y: y)
|
||||
rotate(angle: angle, x: x, y: y)
|
||||
}
|
||||
|
||||
public class func move(dx: Double = 0, dy: Double = 0) -> Transform {
|
||||
return Transform(dx: dx, dy: dy)
|
||||
Transform(dx: dx, dy: dy)
|
||||
}
|
||||
|
||||
public class func move(_ dx: Double, _ dy: Double) -> Transform {
|
||||
return Transform(dx: dx, dy: dy)
|
||||
Transform(dx: dx, dy: dy)
|
||||
}
|
||||
|
||||
public class func scale(sx: Double = 0, sy: Double = 0) -> Transform {
|
||||
return Transform(m11: sx, m22: sy)
|
||||
Transform(m11: sx, m22: sy)
|
||||
}
|
||||
|
||||
public class func scale(_ sx: Double, _ sy: Double) -> Transform {
|
||||
return Transform(m11: sx, m22: sy)
|
||||
Transform(m11: sx, m22: sy)
|
||||
}
|
||||
|
||||
public class func shear(shx: Double = 0, shy: Double = 0) -> Transform {
|
||||
return Transform(m12: shy, m21: shx)
|
||||
Transform(m12: shy, m21: shx)
|
||||
}
|
||||
|
||||
public class func shear(_ shx: Double, _ shy: Double) -> Transform {
|
||||
return Transform(m12: shy, m21: shx)
|
||||
Transform(m12: shy, m21: shx)
|
||||
}
|
||||
|
||||
public class func rotate(angle: Double) -> Transform {
|
||||
@ -106,15 +106,15 @@ public final class Transform {
|
||||
}
|
||||
|
||||
public class func rotate(_ angle: Double) -> Transform {
|
||||
return rotate(angle: angle)
|
||||
rotate(angle: angle)
|
||||
}
|
||||
|
||||
public class func rotate(angle: Double, x: Double = 0, y: Double = 0) -> Transform {
|
||||
return Transform.move(dx: x, dy: y).rotate(angle: angle).move(dx: -x, dy: -y)
|
||||
Transform.move(dx: x, dy: y).rotate(angle: angle).move(dx: -x, dy: -y)
|
||||
}
|
||||
|
||||
public class func rotate(_ angle: Double, _ x: Double, _ y: Double) -> Transform {
|
||||
return rotate(angle: angle, x: x, y: y)
|
||||
rotate(angle: angle, x: x, y: y)
|
||||
}
|
||||
|
||||
public func concat(with: Transform) -> Transform {
|
||||
|
@ -16,7 +16,7 @@ open class TransformedLocus: Locus {
|
||||
}
|
||||
|
||||
open override func bounds() -> Rect {
|
||||
return locus.bounds().applying(transform)
|
||||
locus.bounds().applying(transform)
|
||||
}
|
||||
|
||||
override func equals<T>(other: T) -> Bool where T: Locus {
|
||||
|
@ -2,7 +2,7 @@ open class Group: Node {
|
||||
|
||||
open var contentsVar: AnimatableVariable<[Node]>
|
||||
open var contents: [Node] {
|
||||
get { return contentsVar.value }
|
||||
get { contentsVar.value }
|
||||
set(val) {
|
||||
contentsVar.value = val
|
||||
}
|
||||
@ -127,6 +127,6 @@ open class Group: Node {
|
||||
|
||||
public extension Array where Element: Node {
|
||||
func group( place: Transform = Transform.identity, opaque: Bool = true, opacity: Double = 1, clip: Locus? = nil, effect: Effect? = nil, visible: Bool = true, tag: [String] = []) -> Group {
|
||||
return Group(contents: self, place: place, opaque: opaque, opacity: opacity, clip: clip, effect: effect, visible: visible, tag: tag)
|
||||
Group(contents: self, place: place, opaque: opaque, opacity: opacity, clip: clip, effect: effect, visible: visible, tag: tag)
|
||||
}
|
||||
}
|
||||
|
@ -10,37 +10,37 @@ open class Image: Node {
|
||||
|
||||
public let srcVar: Variable<String>
|
||||
open var src: String {
|
||||
get { return srcVar.value }
|
||||
get { srcVar.value }
|
||||
set(val) { srcVar.value = val }
|
||||
}
|
||||
|
||||
public let xAlignVar: Variable<Align>
|
||||
open var xAlign: Align {
|
||||
get { return xAlignVar.value }
|
||||
get { xAlignVar.value }
|
||||
set(val) { xAlignVar.value = val }
|
||||
}
|
||||
|
||||
public let yAlignVar: Variable<Align>
|
||||
open var yAlign: Align {
|
||||
get { return yAlignVar.value }
|
||||
get { yAlignVar.value }
|
||||
set(val) { yAlignVar.value = val }
|
||||
}
|
||||
|
||||
public let aspectRatioVar: Variable<AspectRatio>
|
||||
open var aspectRatio: AspectRatio {
|
||||
get { return aspectRatioVar.value }
|
||||
get { aspectRatioVar.value }
|
||||
set(val) { aspectRatioVar.value = val }
|
||||
}
|
||||
|
||||
public let wVar: Variable<Int>
|
||||
open var w: Int {
|
||||
get { return wVar.value }
|
||||
get { wVar.value }
|
||||
set(val) { wVar.value = val }
|
||||
}
|
||||
|
||||
public let hVar: Variable<Int>
|
||||
open var h: Int {
|
||||
get { return hVar.value }
|
||||
get { hVar.value }
|
||||
set(val) { hVar.value = val }
|
||||
}
|
||||
|
||||
|
@ -4,37 +4,37 @@ open class Node: Drawable {
|
||||
|
||||
public let placeVar: AnimatableVariable<Transform>
|
||||
open var place: Transform {
|
||||
get { return placeVar.value }
|
||||
get { placeVar.value }
|
||||
set(val) { placeVar.value = val }
|
||||
}
|
||||
|
||||
public let opaqueVar: Variable<Bool>
|
||||
open var opaque: Bool {
|
||||
get { return opaqueVar.value }
|
||||
get { opaqueVar.value }
|
||||
set(val) { opaqueVar.value = val }
|
||||
}
|
||||
|
||||
public let opacityVar: AnimatableVariable<Double>
|
||||
open var opacity: Double {
|
||||
get { return opacityVar.value }
|
||||
get { opacityVar.value }
|
||||
set(val) { opacityVar.value = val }
|
||||
}
|
||||
|
||||
public let clipVar: Variable<Locus?>
|
||||
open var clip: Locus? {
|
||||
get { return clipVar.value }
|
||||
get { clipVar.value }
|
||||
set(val) { clipVar.value = val }
|
||||
}
|
||||
|
||||
public let maskVar: Variable<Node?>
|
||||
open var mask: Node? {
|
||||
get { return maskVar.value }
|
||||
get { maskVar.value }
|
||||
set(val) { maskVar.value = val }
|
||||
}
|
||||
|
||||
public let effectVar: Variable<Effect?>
|
||||
open var effect: Effect? {
|
||||
get { return effectVar.value }
|
||||
get { effectVar.value }
|
||||
set(val) { effectVar.value = val }
|
||||
}
|
||||
|
||||
@ -42,11 +42,11 @@ open class Node: Drawable {
|
||||
|
||||
// MARK: - Searching
|
||||
public func nodeBy(tag: String) -> Node? {
|
||||
return nodeBy(predicate: { $0.tag.contains(tag) })
|
||||
nodeBy(predicate: { $0.tag.contains(tag) })
|
||||
}
|
||||
|
||||
public func nodesBy(tag: String) -> [Node] {
|
||||
return nodesBy(predicate: { $0.tag.contains(tag) })
|
||||
nodesBy(predicate: { $0.tag.contains(tag) })
|
||||
}
|
||||
|
||||
public func nodeBy(predicate: (Node) -> Bool) -> Node? {
|
||||
@ -57,7 +57,7 @@ open class Node: Drawable {
|
||||
}
|
||||
|
||||
public func nodesBy(predicate: (Node) -> Bool) -> [Node] {
|
||||
return [nodeBy(predicate: predicate)].compactMap { $0 }
|
||||
[nodeBy(predicate: predicate)].compactMap { $0 }
|
||||
}
|
||||
|
||||
// MARK: - Events
|
||||
@ -265,35 +265,35 @@ open class Node: Drawable {
|
||||
}
|
||||
|
||||
func shouldCheckForPressed() -> Bool {
|
||||
return !touchPressedHandlers.isEmpty
|
||||
!touchPressedHandlers.isEmpty
|
||||
}
|
||||
|
||||
func shouldCheckForMoved() -> Bool {
|
||||
return !touchMovedHandlers.isEmpty
|
||||
!touchMovedHandlers.isEmpty
|
||||
}
|
||||
|
||||
func shouldCheckForReleased() -> Bool {
|
||||
return !touchReleasedHandlers.isEmpty
|
||||
!touchReleasedHandlers.isEmpty
|
||||
}
|
||||
|
||||
func shouldCheckForTap() -> Bool {
|
||||
return !tapHandlers.isEmpty
|
||||
!tapHandlers.isEmpty
|
||||
}
|
||||
|
||||
func shouldCheckForLongTap() -> Bool {
|
||||
return !longTapHandlers.isEmpty
|
||||
!longTapHandlers.isEmpty
|
||||
}
|
||||
|
||||
func shouldCheckForPan() -> Bool {
|
||||
return !panHandlers.isEmpty
|
||||
!panHandlers.isEmpty
|
||||
}
|
||||
|
||||
func shouldCheckForRotate() -> Bool {
|
||||
return !rotateHandlers.isEmpty
|
||||
!rotateHandlers.isEmpty
|
||||
}
|
||||
|
||||
func shouldCheckForPinch() -> Bool {
|
||||
return !pinchHandlers.isEmpty
|
||||
!pinchHandlers.isEmpty
|
||||
}
|
||||
|
||||
public init(place: Transform = Transform.identity, opaque: Bool = true, opacity: Double = 1, clip: Locus? = nil, mask: Node? = nil, effect: Effect? = nil, visible: Bool = true, tag: [String] = []) {
|
||||
@ -313,7 +313,7 @@ open class Node: Drawable {
|
||||
}
|
||||
|
||||
open var bounds: Rect? {
|
||||
return .none
|
||||
.none
|
||||
}
|
||||
|
||||
// MARK: - Hash
|
||||
|
@ -8,19 +8,19 @@ open class Shape: Node {
|
||||
|
||||
public let formVar: AnimatableVariable<Locus>
|
||||
open var form: Locus {
|
||||
get { return formVar.value }
|
||||
get { formVar.value }
|
||||
set(val) { formVar.value = val }
|
||||
}
|
||||
|
||||
public let fillVar: AnimatableVariable<Fill?>
|
||||
open var fill: Fill? {
|
||||
get { return fillVar.value }
|
||||
get { fillVar.value }
|
||||
set(val) { fillVar.value = val }
|
||||
}
|
||||
|
||||
public let strokeVar: StrokeAnimatableVariable
|
||||
open var stroke: Stroke? {
|
||||
get { return strokeVar.value }
|
||||
get { strokeVar.value }
|
||||
set(val) { strokeVar.value = val }
|
||||
}
|
||||
|
||||
|
@ -8,43 +8,43 @@ open class Text: Node {
|
||||
|
||||
public let textVar: Variable<String>
|
||||
open var text: String {
|
||||
get { return textVar.value }
|
||||
get { textVar.value }
|
||||
set(val) { textVar.value = val }
|
||||
}
|
||||
|
||||
public let fontVar: Variable<Font?>
|
||||
open var font: Font? {
|
||||
get { return fontVar.value }
|
||||
get { fontVar.value }
|
||||
set(val) { fontVar.value = val }
|
||||
}
|
||||
|
||||
public let fillVar: Variable<Fill?>
|
||||
open var fill: Fill? {
|
||||
get { return fillVar.value }
|
||||
get { fillVar.value }
|
||||
set(val) { fillVar.value = val }
|
||||
}
|
||||
|
||||
public let strokeVar: Variable<Stroke?>
|
||||
open var stroke: Stroke? {
|
||||
get { return strokeVar.value }
|
||||
get { strokeVar.value }
|
||||
set(val) { strokeVar.value = val }
|
||||
}
|
||||
|
||||
public let alignVar: Variable<Align>
|
||||
open var align: Align {
|
||||
get { return alignVar.value }
|
||||
get { alignVar.value }
|
||||
set(val) { alignVar.value = val }
|
||||
}
|
||||
|
||||
public let baselineVar: Variable<Baseline>
|
||||
open var baseline: Baseline {
|
||||
get { return baselineVar.value }
|
||||
get { baselineVar.value }
|
||||
set(val) { baselineVar.value = val }
|
||||
}
|
||||
|
||||
public let kerningVar: Variable<Float>
|
||||
open var kerning: Float {
|
||||
get { return kerningVar.value }
|
||||
get { kerningVar.value }
|
||||
set(val) { kerningVar.value = val }
|
||||
}
|
||||
|
||||
|
@ -32,29 +32,29 @@ public typealias MScreen = UIScreen
|
||||
public typealias MViewContentMode = UIView.ContentMode
|
||||
|
||||
func MDefaultRunLoopMode() -> RunLoop.Mode {
|
||||
return RunLoop.Mode.default
|
||||
RunLoop.Mode.default
|
||||
}
|
||||
|
||||
extension MTapGestureRecognizer {
|
||||
func mNumberOfTouches() -> Int {
|
||||
return numberOfTouches
|
||||
numberOfTouches
|
||||
}
|
||||
}
|
||||
|
||||
extension MPanGestureRecognizer {
|
||||
func mNumberOfTouches() -> Int {
|
||||
return numberOfTouches
|
||||
numberOfTouches
|
||||
}
|
||||
|
||||
func mLocationOfTouch(_ touch: Int, inView: UIView?) -> CGPoint {
|
||||
return super.location(ofTouch: touch, in: inView)
|
||||
super.location(ofTouch: touch, in: inView)
|
||||
}
|
||||
}
|
||||
|
||||
extension MRotationGestureRecognizer {
|
||||
final var mRotation: CGFloat {
|
||||
get {
|
||||
return rotation
|
||||
rotation
|
||||
}
|
||||
|
||||
set {
|
||||
@ -66,7 +66,7 @@ extension MRotationGestureRecognizer {
|
||||
extension MPinchGestureRecognizer {
|
||||
var mScale: CGFloat {
|
||||
get {
|
||||
return scale
|
||||
scale
|
||||
}
|
||||
|
||||
set {
|
||||
@ -75,33 +75,33 @@ extension MPinchGestureRecognizer {
|
||||
}
|
||||
|
||||
func mLocationOfTouch(_ touch: Int, inView: UIView?) -> CGPoint {
|
||||
return super.location(ofTouch: touch, in: inView)
|
||||
super.location(ofTouch: touch, in: inView)
|
||||
}
|
||||
}
|
||||
|
||||
extension MFont {
|
||||
class var mSystemFontSize: CGFloat {
|
||||
return UIFont.systemFontSize
|
||||
UIFont.systemFontSize
|
||||
}
|
||||
|
||||
class var mFamilyNames: [String] {
|
||||
return UIFont.familyNames
|
||||
UIFont.familyNames
|
||||
}
|
||||
|
||||
class func mFontNames(forFamily: String) -> [String] {
|
||||
return UIFont.fontNames(forFamilyName: forFamily)
|
||||
UIFont.fontNames(forFamilyName: forFamily)
|
||||
}
|
||||
}
|
||||
|
||||
extension UIScreen {
|
||||
var mScale: CGFloat {
|
||||
return self.scale
|
||||
self.scale
|
||||
}
|
||||
}
|
||||
|
||||
extension UIBezierPath {
|
||||
var mUsesEvenOddFillRule: Bool {
|
||||
return self.usesEvenOddFillRule
|
||||
self.usesEvenOddFillRule
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,11 +12,11 @@ import Foundation
|
||||
import UIKit
|
||||
|
||||
func MGraphicsGetCurrentContext() -> CGContext? {
|
||||
return UIGraphicsGetCurrentContext()
|
||||
UIGraphicsGetCurrentContext()
|
||||
}
|
||||
|
||||
func MGraphicsGetImageFromCurrentImageContext() -> MImage! {
|
||||
return UIGraphicsGetImageFromCurrentImageContext()
|
||||
UIGraphicsGetImageFromCurrentImageContext()
|
||||
}
|
||||
|
||||
func MGraphicsPushContext(_ context: CGContext) {
|
||||
@ -32,15 +32,15 @@ func MGraphicsEndImageContext() {
|
||||
}
|
||||
|
||||
func MImagePNGRepresentation(_ image: MImage) -> Data? {
|
||||
return image.pngData()
|
||||
image.pngData()
|
||||
}
|
||||
|
||||
func MImageJPEGRepresentation(_ image: MImage, _ quality: CGFloat = 0.8) -> Data? {
|
||||
return image.jpegData(compressionQuality: quality)
|
||||
image.jpegData(compressionQuality: quality)
|
||||
}
|
||||
|
||||
func MMainScreen() -> MScreen? {
|
||||
return MScreen.main
|
||||
MScreen.main
|
||||
}
|
||||
|
||||
func MGraphicsBeginImageContextWithOptions(_ size: CGSize, _ opaque: Bool, _ scale: CGFloat) {
|
||||
@ -48,7 +48,7 @@ func MGraphicsBeginImageContextWithOptions(_ size: CGSize, _ opaque: Bool, _ sca
|
||||
}
|
||||
|
||||
func MNoIntrinsicMetric() -> CGFloat {
|
||||
return UIView.noIntrinsicMetric
|
||||
UIView.noIntrinsicMetric
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -13,11 +13,11 @@ import UIKit
|
||||
|
||||
open class MView: UIView, Touchable {
|
||||
var mLayer: CALayer? {
|
||||
return self.layer
|
||||
self.layer
|
||||
}
|
||||
|
||||
var mGestureRecognizers: [MGestureRecognizer]? {
|
||||
return self.gestureRecognizers
|
||||
self.gestureRecognizers
|
||||
}
|
||||
|
||||
func removeGestureRecognizers() {
|
||||
|
@ -31,41 +31,41 @@ public typealias MRotationGestureRecognizer = NSRotationGestureRecognizer
|
||||
public typealias MScreen = NSScreen
|
||||
|
||||
func MDefaultRunLoopMode() -> RunLoop.Mode {
|
||||
return RunLoop.Mode.default
|
||||
RunLoop.Mode.default
|
||||
}
|
||||
|
||||
extension MGestureRecognizer {
|
||||
var cancelsTouchesInView: Bool {
|
||||
get {
|
||||
return false
|
||||
false
|
||||
} set { }
|
||||
}
|
||||
}
|
||||
|
||||
extension MTapGestureRecognizer {
|
||||
func mNumberOfTouches() -> Int {
|
||||
return 1
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
extension MPanGestureRecognizer {
|
||||
func mNumberOfTouches() -> Int {
|
||||
return 1
|
||||
1
|
||||
}
|
||||
|
||||
func mLocationOfTouch(_ touch: Int, inView: NSView?) -> NSPoint {
|
||||
return super.location(in: inView)
|
||||
super.location(in: inView)
|
||||
}
|
||||
}
|
||||
|
||||
extension MRotationGestureRecognizer {
|
||||
var velocity: CGFloat {
|
||||
return 0.1
|
||||
0.1
|
||||
}
|
||||
|
||||
var mRotation: CGFloat {
|
||||
get {
|
||||
return -rotation
|
||||
-rotation
|
||||
}
|
||||
|
||||
set {
|
||||
@ -77,7 +77,7 @@ extension MRotationGestureRecognizer {
|
||||
extension MPinchGestureRecognizer {
|
||||
var mScale: CGFloat {
|
||||
get {
|
||||
return magnification + 1.0
|
||||
magnification + 1.0
|
||||
}
|
||||
|
||||
set {
|
||||
@ -86,21 +86,21 @@ extension MPinchGestureRecognizer {
|
||||
}
|
||||
|
||||
func mLocationOfTouch(_ touch: Int, inView view: NSView?) -> NSPoint {
|
||||
return super.location(in: view)
|
||||
super.location(in: view)
|
||||
}
|
||||
}
|
||||
|
||||
extension NSFont {
|
||||
var lineHeight: CGFloat {
|
||||
return self.boundingRectForFont.size.height
|
||||
self.boundingRectForFont.size.height
|
||||
}
|
||||
|
||||
class var mSystemFontSize: CGFloat {
|
||||
return NSFont.systemFontSize
|
||||
NSFont.systemFontSize
|
||||
}
|
||||
|
||||
class var mFamilyNames: [String] {
|
||||
return NSFontManager.shared.availableFontFamilies
|
||||
NSFontManager.shared.availableFontFamilies
|
||||
}
|
||||
|
||||
class func mFontNames(forFamily: String) -> [String] {
|
||||
@ -117,13 +117,13 @@ extension NSFont {
|
||||
|
||||
extension NSScreen {
|
||||
var mScale: CGFloat {
|
||||
return self.backingScaleFactor
|
||||
self.backingScaleFactor
|
||||
}
|
||||
}
|
||||
|
||||
extension NSImage {
|
||||
var cgImage: CGImage? {
|
||||
return self.cgImage(forProposedRect: nil, context: nil, hints: nil)
|
||||
self.cgImage(forProposedRect: nil, context: nil, hints: nil)
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,12 +138,12 @@ extension NSTouch {
|
||||
extension NSString {
|
||||
@nonobjc
|
||||
func size(attributes attrs: [NSAttributedString.Key: Any]? = nil) -> NSSize {
|
||||
return size(withAttributes: attrs)
|
||||
size(withAttributes: attrs)
|
||||
}
|
||||
}
|
||||
|
||||
func MMainScreen() -> MScreen? {
|
||||
return MScreen.main
|
||||
MScreen.main
|
||||
}
|
||||
|
||||
extension MBezierPath {
|
||||
@ -168,7 +168,7 @@ extension CGContext {
|
||||
|
||||
var scale: CGFloat {
|
||||
get {
|
||||
return CGContextScale._scale
|
||||
CGContextScale._scale
|
||||
}
|
||||
|
||||
set(newValue) {
|
||||
@ -186,7 +186,7 @@ extension NSWindow {
|
||||
|
||||
extension NSBezierPath {
|
||||
var mUsesEvenOddFillRule: Bool {
|
||||
return self.windingRule == .evenOdd
|
||||
self.windingRule == .evenOdd
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import Foundation
|
||||
import AppKit
|
||||
|
||||
func MGraphicsGetCurrentContext() -> CGContext? {
|
||||
return NSGraphicsContext.current?.cgContext
|
||||
NSGraphicsContext.current?.cgContext
|
||||
}
|
||||
|
||||
func MGraphicsPushContext(_ context: CGContext) {
|
||||
@ -81,7 +81,7 @@ func MGraphicsEndImageContext() {
|
||||
}
|
||||
|
||||
func MNoIntrinsicMetric() -> CGFloat {
|
||||
return NSView.noIntrinsicMetric
|
||||
NSView.noIntrinsicMetric
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -20,7 +20,7 @@ public struct MRectCorner: OptionSet {
|
||||
public static let bottomLeft = MRectCorner(rawValue: 1 << 2)
|
||||
public static let bottomRight = MRectCorner(rawValue: 1 << 3)
|
||||
public static var allCorners: MRectCorner {
|
||||
return [.topLeft, .topRight, .bottomLeft, .bottomRight]
|
||||
[.topLeft, .topRight, .bottomLeft, .bottomRight]
|
||||
}
|
||||
|
||||
public init(rawValue: UInt) {
|
||||
|
@ -41,16 +41,16 @@ open class MView: NSView, Touchable {
|
||||
}
|
||||
|
||||
open override var isFlipped: Bool {
|
||||
return true
|
||||
true
|
||||
}
|
||||
|
||||
var mGestureRecognizers: [NSGestureRecognizer]? {
|
||||
return self.gestureRecognizers
|
||||
self.gestureRecognizers
|
||||
}
|
||||
|
||||
open var backgroundColor: MColor? {
|
||||
get {
|
||||
return self.layer?.backgroundColor == nil ? nil : NSColor(cgColor: self.layer!.backgroundColor!)
|
||||
self.layer?.backgroundColor == nil ? nil : NSColor(cgColor: self.layer!.backgroundColor!)
|
||||
}
|
||||
|
||||
set {
|
||||
@ -59,7 +59,7 @@ open class MView: NSView, Touchable {
|
||||
}
|
||||
|
||||
var mLayer: CALayer? {
|
||||
return self.layer
|
||||
self.layer
|
||||
}
|
||||
|
||||
var contentMode: MViewContentMode = .scaleToFill
|
||||
|
@ -10,7 +10,7 @@ class GroupRenderer: NodeRenderer {
|
||||
var renderers: [NodeRenderer] = []
|
||||
|
||||
override var node: Node {
|
||||
return group
|
||||
group
|
||||
}
|
||||
|
||||
init(group: Group, view: DrawingView?, parentRenderer: GroupRenderer? = nil) {
|
||||
|
@ -14,7 +14,7 @@ class ImageRenderer: NodeRenderer {
|
||||
var renderedPaths: [CGPath] = [CGPath]()
|
||||
|
||||
override var node: Node {
|
||||
return image
|
||||
image
|
||||
}
|
||||
|
||||
init(image: Image, view: DrawingView?, parentRenderer: GroupRenderer? = nil) {
|
||||
|
@ -24,7 +24,7 @@ class NodeRenderer {
|
||||
|
||||
weak var view: DrawingView?
|
||||
var sceneLayer: CALayer? {
|
||||
return view?.mLayer
|
||||
view?.mLayer
|
||||
}
|
||||
var layer: CachedLayer?
|
||||
var zPosition: Int = 0
|
||||
@ -312,7 +312,7 @@ class NodeRenderer {
|
||||
}
|
||||
|
||||
public func doFindNodeAt(path: NodePath, ctx: CGContext) -> NodePath? {
|
||||
return nil
|
||||
nil
|
||||
}
|
||||
|
||||
func calculateZPositionRecursively() {
|
||||
|
@ -76,7 +76,7 @@ class RenderUtils {
|
||||
}
|
||||
|
||||
class func applyOpacity(_ color: Color, opacity: Double) -> Color {
|
||||
return Color.rgba(r: color.r(), g: color.g(), b: color.b(), a: Double(color.a()) / 255.0 * opacity)
|
||||
Color.rgba(r: color.r(), g: color.g(), b: color.b(), a: Double(color.a()) / 255.0 * opacity)
|
||||
}
|
||||
|
||||
class func toCGPath(_ locus: Locus) -> CGPath {
|
||||
@ -537,7 +537,7 @@ class RenderUtils {
|
||||
}
|
||||
|
||||
class func num2bool(_ double: Double) -> Bool {
|
||||
return double > 0.5 ? true : false
|
||||
double > 0.5 ? true : false
|
||||
}
|
||||
|
||||
internal class func setStrokeAttributes(_ stroke: Stroke, ctx: CGContext?) {
|
||||
|
@ -20,7 +20,7 @@ class ShapeRenderer: NodeRenderer {
|
||||
}
|
||||
|
||||
override var node: Node {
|
||||
return shape
|
||||
shape
|
||||
}
|
||||
|
||||
override func doAddObservers() {
|
||||
@ -231,10 +231,10 @@ class ShapeRenderer: NodeRenderer {
|
||||
|
||||
extension Stroke {
|
||||
func strokeUsingAlphaOnly() -> Stroke {
|
||||
return Stroke(fill: fill.fillUsingAlphaOnly(), width: width, cap: cap, join: join, dashes: dashes, offset: offset)
|
||||
Stroke(fill: fill.fillUsingAlphaOnly(), width: width, cap: cap, join: join, dashes: dashes, offset: offset)
|
||||
}
|
||||
func strokeUsingGrayscaleNoAlpha() -> Stroke {
|
||||
return Stroke(fill: fill.fillUsingGrayscaleNoAlpha(), width: width, cap: cap, join: join, dashes: dashes, offset: offset)
|
||||
Stroke(fill: fill.fillUsingGrayscaleNoAlpha(), width: width, cap: cap, join: join, dashes: dashes, offset: offset)
|
||||
}
|
||||
}
|
||||
|
||||
@ -268,7 +268,7 @@ extension Fill {
|
||||
|
||||
extension Color {
|
||||
func colorUsingAlphaOnly() -> Color {
|
||||
return Color.black.with(a: Double(a()) / 255.0)
|
||||
Color.black.with(a: Double(a()) / 255.0)
|
||||
}
|
||||
|
||||
func toGrayscaleNoAlpha() -> Color {
|
||||
|
@ -10,7 +10,7 @@ class TextRenderer: NodeRenderer {
|
||||
var text: Text
|
||||
|
||||
override var node: Node {
|
||||
return text
|
||||
text
|
||||
}
|
||||
|
||||
init(text: Text, view: DrawingView?, parentRenderer: GroupRenderer? = nil) {
|
||||
|
@ -336,7 +336,7 @@ open class SVGConstants {
|
||||
#endif
|
||||
|
||||
public static func valueToColor(_ color: Int) -> String? {
|
||||
return SVGConstants.colorList.filter { _, v -> Bool in v == color }.map { k, _ -> String in k }.first
|
||||
SVGConstants.colorList.filter { _, v -> Bool in v == color }.map { k, _ -> String in k }.first
|
||||
}
|
||||
|
||||
public static let defaultStrokeLineCap = LineCap.butt
|
||||
|
@ -32,7 +32,7 @@ class SVGSize {
|
||||
}
|
||||
|
||||
func toPixels(total: Size) -> Size {
|
||||
return Size(w: width.toPixels(total: total.w),
|
||||
Size(w: width.toPixels(total: total.w),
|
||||
h: height.toPixels(total: total.h))
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ class SVGNodeLayout: NodeLayout {
|
||||
}
|
||||
|
||||
func computeSize(parent: Size) -> Size {
|
||||
return svgSize.toPixels(total: parent)
|
||||
svgSize.toPixels(total: parent)
|
||||
}
|
||||
|
||||
func layout(node: Node, in size: Size) {
|
||||
|
@ -37,7 +37,7 @@ open class SVGParser {
|
||||
/// - Throws: An SVGParserError of no such file
|
||||
@available(*, deprecated)
|
||||
open class func parse(path: String, ofType: String = "svg") throws -> Node {
|
||||
return try SVGParser.parse(bundle: Bundle.main, path: path, ofType: ofType)
|
||||
try SVGParser.parse(bundle: Bundle.main, path: path, ofType: ofType)
|
||||
}
|
||||
|
||||
/// Parse an SVG file
|
||||
@ -74,7 +74,7 @@ open class SVGParser {
|
||||
/// Parse the specified content of an SVG file.
|
||||
/// - returns: Root node of the corresponding Macaw scene.
|
||||
open class func parse(text: String) throws -> Node {
|
||||
return try SVGParser(text).parse()
|
||||
try SVGParser(text).parse()
|
||||
}
|
||||
|
||||
let availableStyleAttributes = ["stroke",
|
||||
@ -909,7 +909,7 @@ open class SVGParser {
|
||||
}
|
||||
|
||||
fileprivate func getOpacity(_ opacity: String) -> Double {
|
||||
return Double(opacity.replacingOccurrences(of: " ", with: "")) ?? 1
|
||||
Double(opacity.replacingOccurrences(of: " ", with: "")) ?? 1
|
||||
}
|
||||
|
||||
fileprivate func parseLine(_ line: XMLIndexer) -> Line? {
|
||||
@ -1236,7 +1236,7 @@ open class SVGParser {
|
||||
fontName: String?,
|
||||
fontWeight: String?,
|
||||
fontSize: Int?) -> Font {
|
||||
return Font(
|
||||
Font(
|
||||
name: getFontName(attributes) ?? fontName ?? "Serif",
|
||||
size: getFontSize(attributes) ?? fontSize ?? 12,
|
||||
weight: getFontWeight(attributes) ?? fontWeight ?? "normal")
|
||||
@ -1726,7 +1726,7 @@ open class SVGParser {
|
||||
}
|
||||
|
||||
fileprivate func getFontName(_ attributes: [String: String]) -> String? {
|
||||
return attributes["font-family"]?.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
attributes["font-family"]?.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
}
|
||||
|
||||
fileprivate func getFontSize(_ attributes: [String: String]) -> Int? {
|
||||
@ -1895,7 +1895,7 @@ open class SVGParser {
|
||||
}
|
||||
|
||||
fileprivate func degreesToRadians(_ degrees: Double) -> Double {
|
||||
return degrees * .pi / 180
|
||||
degrees * .pi / 180
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -108,23 +108,23 @@ open class SVGSerializer {
|
||||
}
|
||||
|
||||
fileprivate func lineToSVG(_ line: Line) -> String {
|
||||
return tag(SVGLineOpenTag, ["x1": line.x1.serialize(), "y1": line.y1.serialize(), "x2": line.x2.serialize(), "y2": line.y2.serialize()])
|
||||
tag(SVGLineOpenTag, ["x1": line.x1.serialize(), "y1": line.y1.serialize(), "x2": line.x2.serialize(), "y2": line.y2.serialize()])
|
||||
}
|
||||
|
||||
fileprivate func ellipseToSVG(_ ellipse: Ellipse) -> String {
|
||||
return tag(SVGEllipseOpenTag, ["cx": ellipse.cx.serialize(), "cy": ellipse.cy.serialize(), "rx": ellipse.rx.serialize(), "ry": ellipse.ry.serialize()])
|
||||
tag(SVGEllipseOpenTag, ["cx": ellipse.cx.serialize(), "cy": ellipse.cy.serialize(), "rx": ellipse.rx.serialize(), "ry": ellipse.ry.serialize()])
|
||||
}
|
||||
|
||||
fileprivate func circleToSVG(_ circle: Circle) -> String {
|
||||
return tag(SVGCircleOpenTag, ["cx": circle.cx.serialize(), "cy": circle.cy.serialize(), "r": circle.r.serialize()])
|
||||
tag(SVGCircleOpenTag, ["cx": circle.cx.serialize(), "cy": circle.cy.serialize(), "r": circle.r.serialize()])
|
||||
}
|
||||
|
||||
fileprivate func roundRectToSVG(_ roundRect: RoundRect) -> String {
|
||||
return tag(SVGRectOpenTag, ["x": roundRect.rect.x.serialize(), "y": roundRect.rect.y.serialize(), "width": roundRect.rect.w.serialize(), "height": roundRect.rect.h.serialize(), "rx": roundRect.rx.serialize(), "ry": roundRect.ry.serialize()])
|
||||
tag(SVGRectOpenTag, ["x": roundRect.rect.x.serialize(), "y": roundRect.rect.y.serialize(), "width": roundRect.rect.w.serialize(), "height": roundRect.rect.h.serialize(), "rx": roundRect.rx.serialize(), "ry": roundRect.ry.serialize()])
|
||||
}
|
||||
|
||||
fileprivate func rectToSVG(_ rect: Rect) -> String {
|
||||
return tag(SVGRectOpenTag, ["x": rect.x.serialize(), "y": rect.y.serialize(), "width": rect.w.serialize(), "height": rect.h.serialize()])
|
||||
tag(SVGRectOpenTag, ["x": rect.x.serialize(), "y": rect.y.serialize(), "width": rect.w.serialize(), "height": rect.h.serialize()])
|
||||
}
|
||||
|
||||
fileprivate func imageToSVG(_ image: Image) -> String {
|
||||
@ -398,7 +398,7 @@ open class SVGSerializer {
|
||||
}
|
||||
|
||||
open class func serialize(node: Node, width: Int? = nil, height: Int? = nil, id: String? = nil) -> String {
|
||||
return SVGSerializer(width: width, height: height, id: id).serializeRootNode(node: node)
|
||||
SVGSerializer(width: width, height: height, id: id).serializeRootNode(node: node)
|
||||
}
|
||||
|
||||
}
|
||||
|
2
Source/thirdparty/CAAnimationClosure.swift
vendored
2
Source/thirdparty/CAAnimationClosure.swift
vendored
@ -139,7 +139,7 @@ public extension CAAnimation {
|
||||
}
|
||||
|
||||
get {
|
||||
return animating
|
||||
animating
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
Source/thirdparty/CGFloat+Double.swift
vendored
2
Source/thirdparty/CGFloat+Double.swift
vendored
@ -7,6 +7,6 @@ import UIKit
|
||||
internal extension CGFloat {
|
||||
|
||||
var doubleValue: Double {
|
||||
return Double(self)
|
||||
Double(self)
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public extension Color {
|
||||
public extension Transform {
|
||||
|
||||
func toCG() -> CGAffineTransform {
|
||||
return CGAffineTransform(a: CGFloat(m11), b: CGFloat(m12), c: CGFloat(m21),
|
||||
CGAffineTransform(a: CGFloat(m11), b: CGFloat(m12), c: CGFloat(m21),
|
||||
d: CGFloat(m22), tx: CGFloat(dx), ty: CGFloat(dy))
|
||||
}
|
||||
|
||||
@ -65,11 +65,11 @@ public extension LineCap {
|
||||
public extension Rect {
|
||||
|
||||
func toCG() -> CGRect {
|
||||
return CGRect(x: self.x, y: self.y, width: self.w, height: self.h)
|
||||
CGRect(x: self.x, y: self.y, width: self.w, height: self.h)
|
||||
}
|
||||
|
||||
func applying(_ t: Transform) -> Rect {
|
||||
return toCG().applying(t.toCG()).toMacaw()
|
||||
toCG().applying(t.toCG()).toMacaw()
|
||||
}
|
||||
|
||||
}
|
||||
@ -77,7 +77,7 @@ public extension Rect {
|
||||
public extension CGRect {
|
||||
|
||||
func toMacaw() -> Rect {
|
||||
return Rect(x: Double(origin.x),
|
||||
Rect(x: Double(origin.x),
|
||||
y: Double(origin.y),
|
||||
w: Double(size.width),
|
||||
h: Double(size.height))
|
||||
@ -88,7 +88,7 @@ public extension CGRect {
|
||||
public extension Size {
|
||||
|
||||
func toCG() -> CGSize {
|
||||
return CGSize(width: self.w, height: self.h)
|
||||
CGSize(width: self.w, height: self.h)
|
||||
}
|
||||
|
||||
}
|
||||
@ -96,7 +96,7 @@ public extension Size {
|
||||
public extension CGSize {
|
||||
|
||||
func toMacaw() -> Size {
|
||||
return Size(w: Double(width),
|
||||
Size(w: Double(width),
|
||||
h: Double(height))
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ public extension CGSize {
|
||||
public extension Point {
|
||||
|
||||
func toCG() -> CGPoint {
|
||||
return CGPoint(x: self.x, y: self.y)
|
||||
CGPoint(x: self.x, y: self.y)
|
||||
}
|
||||
|
||||
}
|
||||
@ -113,7 +113,7 @@ public extension Point {
|
||||
public extension CGPoint {
|
||||
|
||||
func toMacaw() -> Point {
|
||||
return Point(x: Double(x), y: Double(y))
|
||||
Point(x: Double(x), y: Double(y))
|
||||
}
|
||||
|
||||
}
|
||||
@ -121,7 +121,7 @@ public extension CGPoint {
|
||||
public extension Locus {
|
||||
|
||||
func toCGPath() -> CGPath {
|
||||
return RenderUtils.toCGPath(self)
|
||||
RenderUtils.toCGPath(self)
|
||||
}
|
||||
|
||||
}
|
||||
@ -129,7 +129,7 @@ public extension Locus {
|
||||
public extension CGAffineTransform {
|
||||
|
||||
func toMacaw() -> Transform {
|
||||
return Transform(m11: Double(a), m12: Double(b), m21: Double(c), m22: Double(d), dx: Double(tx), dy: Double(ty))
|
||||
Transform(m11: Double(a), m12: Double(b), m21: Double(c), m22: Double(d), dx: Double(tx), dy: Double(ty))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,6 @@ import Foundation
|
||||
|
||||
extension Rect: CustomStringConvertible {
|
||||
public var description: String {
|
||||
return "x: \(String(format: "%f", x)), y: \(String(format: "%f", y)), w: \(String(format: "%f", w)), h: \(String(format: "%f", h))"
|
||||
"x: \(String(format: "%f", x)), y: \(String(format: "%f", y)), w: \(String(format: "%f", w)), h: \(String(format: "%f", h))"
|
||||
}
|
||||
}
|
||||
|
@ -18,26 +18,26 @@ open class MacawView: MView, MGestureRecognizerDelegate {
|
||||
public lazy var zoom = MacawZoom(view: self)
|
||||
|
||||
open var node: Node {
|
||||
get { return drawingView.node }
|
||||
get { drawingView.node }
|
||||
set { drawingView.node = newValue }
|
||||
}
|
||||
|
||||
open var contentLayout: ContentLayout {
|
||||
get { return drawingView.contentLayout }
|
||||
get { drawingView.contentLayout }
|
||||
set { drawingView.contentLayout = newValue }
|
||||
}
|
||||
|
||||
open override var contentMode: MViewContentMode {
|
||||
get { return drawingView.contentMode }
|
||||
get { drawingView.contentMode }
|
||||
set { drawingView.contentMode = newValue }
|
||||
}
|
||||
|
||||
open var place: Transform {
|
||||
get { return drawingView.place }
|
||||
get { drawingView.place }
|
||||
}
|
||||
|
||||
open var placeVar: Variable<Transform> {
|
||||
get { return drawingView.placeVar }
|
||||
get { drawingView.placeVar }
|
||||
}
|
||||
|
||||
override open var frame: CGRect {
|
||||
@ -48,11 +48,11 @@ open class MacawView: MView, MGestureRecognizerDelegate {
|
||||
}
|
||||
|
||||
override open var intrinsicContentSize: CGSize {
|
||||
get { return drawingView.intrinsicContentSize }
|
||||
get { drawingView.intrinsicContentSize }
|
||||
}
|
||||
|
||||
internal var renderer: NodeRenderer? {
|
||||
get { return drawingView.renderer }
|
||||
get { drawingView.renderer }
|
||||
set { drawingView.renderer = newValue }
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ open class MacawView: MView, MGestureRecognizerDelegate {
|
||||
}
|
||||
|
||||
public final func findNodeAt(location: CGPoint) -> Node? {
|
||||
return drawingView.findNodeAt(location: location)
|
||||
drawingView.findNodeAt(location: location)
|
||||
}
|
||||
|
||||
private func onZoomChange(t: Transform) {
|
||||
@ -186,7 +186,7 @@ open class MacawView: MView, MGestureRecognizerDelegate {
|
||||
}
|
||||
|
||||
private func convert(touches: Set<MTouch>) -> [MTouchEvent] {
|
||||
return touches.map { touch -> MTouchEvent in
|
||||
touches.map { touch -> MTouchEvent in
|
||||
let location = touch.location(in: self).toMacaw()
|
||||
let id = Int(bitPattern: Unmanaged.passUnretained(touch).toOpaque())
|
||||
return MTouchEvent(x: Double(location.x), y: Double(location.y), id: id)
|
||||
@ -196,11 +196,11 @@ open class MacawView: MView, MGestureRecognizerDelegate {
|
||||
// MARK: - MGestureRecognizerDelegate
|
||||
|
||||
public func gestureRecognizer(_ gestureRecognizer: MGestureRecognizer, shouldReceive touch: MTouch) -> Bool {
|
||||
return true
|
||||
true
|
||||
}
|
||||
|
||||
public func gestureRecognizer(_ gestureRecognizer: MGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: MGestureRecognizer) -> Bool {
|
||||
return true
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,11 +237,11 @@ internal class DrawingView: MView {
|
||||
}
|
||||
|
||||
var place: Transform {
|
||||
return placeManager.placeVar.value
|
||||
placeManager.placeVar.value
|
||||
}
|
||||
|
||||
var placeVar: Variable<Transform> {
|
||||
return placeManager.placeVar
|
||||
placeManager.placeVar
|
||||
}
|
||||
|
||||
override open var frame: CGRect {
|
||||
|
@ -117,11 +117,11 @@ fileprivate class ZoomData {
|
||||
}
|
||||
|
||||
func transform() -> Transform {
|
||||
return Transform.move(dx: offset.w, dy: offset.h).scale(sx: scale, sy: scale).rotate(angle: angle)
|
||||
Transform.move(dx: offset.w, dy: offset.h).scale(sx: scale, sy: scale).rotate(angle: angle)
|
||||
}
|
||||
|
||||
func move(delta: Size) -> ZoomData {
|
||||
return ZoomData(offset: offset + delta, scale: scale, angle: angle)
|
||||
ZoomData(offset: offset + delta, scale: scale, angle: angle)
|
||||
}
|
||||
|
||||
func combine(with: ZoomData) -> ZoomData {
|
||||
@ -151,7 +151,7 @@ fileprivate class TouchData {
|
||||
}
|
||||
|
||||
func current(in view: MacawView) -> Point {
|
||||
return touch.location(in: view).toMacaw()
|
||||
touch.location(in: view).toMacaw()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ class MTouchEvent: Hashable {
|
||||
}
|
||||
|
||||
public static func == (lhs: MTouchEvent, rhs: MTouchEvent) -> Bool {
|
||||
return lhs.id == rhs.id
|
||||
lhs.id == rhs.id
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user