From 65f358425f0f6b33b99ea012cdd869117302fab3 Mon Sep 17 00:00:00 2001 From: Jonathan Chong Date: Fri, 26 May 2023 09:20:22 -0700 Subject: [PATCH] Update minimum deployment version of ios to 11.0 --- Example/Example.xcodeproj/project.pbxproj | 4 +- Macaw.podspec | 2 +- Macaw.xcodeproj/project.pbxproj | 10 +++- Package.swift | 2 +- README.md | 2 +- Source/animation/Animation.swift | 16 +++--- Source/animation/AnimationImpl.swift | 10 ++-- Source/animation/AnimationUtils.swift | 2 +- Source/animation/Easing.swift | 10 ++-- .../Extensions/AnimOperators.swift | 6 +- .../Extensions/ContentsInterpolation.swift | 2 +- .../Extensions/DoubleInterpolation.swift | 2 +- .../Extensions/FillInterpolation.swift | 2 +- .../Extensions/LocusInterpolation.swift | 2 +- .../Extensions/ShapeInterpolation.swift | 2 +- .../Extensions/StrokeInterpolation.swift | 2 +- .../Extensions/TransformInterpolation.swift | 2 +- .../layer_animation/PathFunctions.swift | 2 +- .../animation/types/MorphingAnimation.swift | 6 +- Source/animation/types/OpacityAnimation.swift | 4 +- Source/animation/types/PathAnimation.swift | 11 ++-- Source/animation/types/ShapeAnimation.swift | 2 +- .../animation/types/TransformAnimation.swift | 6 +- .../Cache/AnimationCache.swift | 6 +- .../Cache/NodeHashable.swift | 4 +- .../Cache/TransformHashable.swift | 2 +- .../PathAnimationGenerator.swift | 4 +- Source/bindings/Variable.swift | 2 +- Source/events/TouchEvent.swift | 2 +- Source/layout/ContentLayout.swift | 6 +- Source/model/draw/Align.swift | 8 +-- Source/model/draw/AspectRatio.swift | 8 +-- Source/model/draw/Color.swift | 14 ++--- Source/model/draw/Effect.swift | 12 ++-- Source/model/draw/Fill.swift | 2 +- Source/model/draw/Stop.swift | 2 +- Source/model/draw/Stroke.swift | 2 +- Source/model/geom2d/Arc.swift | 2 +- Source/model/geom2d/Circle.swift | 6 +- Source/model/geom2d/Ellipse.swift | 4 +- Source/model/geom2d/GeomUtils.swift | 2 +- Source/model/geom2d/Line.swift | 4 +- Source/model/geom2d/Locus.swift | 18 +++--- Source/model/geom2d/Path.swift | 4 +- Source/model/geom2d/PathBuilder.swift | 56 +++++++++---------- Source/model/geom2d/PathSegment.swift | 2 +- Source/model/geom2d/Point.swift | 10 ++-- Source/model/geom2d/Rect.swift | 20 +++---- Source/model/geom2d/RoundRect.swift | 2 +- Source/model/geom2d/Size.swift | 10 ++-- Source/model/geom2d/Transform.swift | 36 ++++++------ Source/model/geom2d/TransformedLocus.swift | 2 +- Source/model/scene/Group.swift | 4 +- Source/model/scene/Image.swift | 12 ++-- Source/model/scene/Node.swift | 36 ++++++------ Source/model/scene/Shape.swift | 6 +- Source/model/scene/Text.swift | 14 ++--- Source/platform/iOS/Common_iOS.swift | 24 ++++---- Source/platform/iOS/Graphics_iOS.swift | 12 ++-- Source/platform/iOS/MView_iOS.swift | 4 +- Source/platform/macOS/Common_macOS.swift | 36 ++++++------ Source/platform/macOS/Graphics_macOS.swift | 4 +- .../macOS/MBezierPath+Extension_macOS.swift | 2 +- Source/platform/macOS/MView_macOS.swift | 8 +-- Source/render/GroupRenderer.swift | 2 +- Source/render/ImageRenderer.swift | 2 +- Source/render/NodeRenderer.swift | 6 +- Source/render/RenderUtils.swift | 4 +- Source/render/ShapeRenderer.swift | 8 +-- Source/render/TextRenderer.swift | 2 +- Source/svg/SVGConstants.swift | 2 +- Source/svg/SVGNodeLayout.swift | 4 +- Source/svg/SVGParser.swift | 20 +++---- Source/svg/SVGSerializer.swift | 14 ++--- Source/thirdparty/CAAnimationClosure.swift | 2 +- Source/thirdparty/CGFloat+Double.swift | 2 +- Source/utils/CGMappings.swift | 22 ++++---- Source/utils/DescriptionExtensions.swift | 2 +- Source/views/MacawView.swift | 26 ++++----- Source/views/MacawZoom.swift | 6 +- Source/views/Touchable.swift | 2 +- 81 files changed, 326 insertions(+), 323 deletions(-) diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index 1315fb84..af1186c1 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -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)"; diff --git a/Macaw.podspec b/Macaw.podspec index d46b8b5f..fef37762 100644 --- a/Macaw.podspec +++ b/Macaw.podspec @@ -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" diff --git a/Macaw.xcodeproj/project.pbxproj b/Macaw.xcodeproj/project.pbxproj index 476aa23d..f24d11bd 100644 --- a/Macaw.xcodeproj/project.pbxproj +++ b/Macaw.xcodeproj/project.pbxproj @@ -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 = ""; }; A74C832D229FBA4C0085A832 /* color-prop-04-t-manual-osx.reference */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "color-prop-04-t-manual-osx.reference"; sourceTree = ""; }; A7E675551EC4213500BD9ECB /* NodeBoundsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NodeBoundsTests.swift; path = Bounds/NodeBoundsTests.swift; sourceTree = ""; }; - A7F46DE9270B2219008DA1DF /* CommonError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonError.swift; sourceTree = ""; }; A7F46DDD270B0EE8008DA1DF /* XMLHash.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XMLHash.swift; sourceTree = ""; }; A7F46DDE270B0EE8008DA1DF /* shim.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = shim.swift; sourceTree = ""; }; A7F46DDF270B0EE8008DA1DF /* XMLIndexer+XMLIndexerDeserializable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "XMLIndexer+XMLIndexerDeserializable.swift"; sourceTree = ""; }; + A7F46DE9270B2219008DA1DF /* CommonError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonError.swift; sourceTree = ""; }; C410148D1F834D280022EE44 /* style.svg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = style.svg; sourceTree = ""; }; C4153A8E1F8793DD001BA5EE /* small-logo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "small-logo.png"; sourceTree = ""; }; C43B064C1F9738EF00787A35 /* clip.svg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = clip.svg; sourceTree = ""; }; @@ -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)"; diff --git a/Package.swift b/Package.swift index bf26750c..bbab57b2 100644 --- a/Package.swift +++ b/Package.swift @@ -6,7 +6,7 @@ let package = Package( name: "Macaw", platforms: [ .macOS(.v10_12), - .iOS(.v9) + .iOS(.v11) ], products: [ .library( diff --git a/README.md b/README.md index 8aff8eeb..6e8a1b91 100644 --- a/README.md +++ b/README.md @@ -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+ diff --git a/Source/animation/Animation.swift b/Source/animation/Animation.swift index 9db2a92a..8a1a7f14 100644 --- a/Source/animation/Animation.swift +++ b/Source/animation/Animation.swift @@ -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 } } diff --git a/Source/animation/AnimationImpl.swift b/Source/animation/AnimationImpl.swift index 2161999f..c4d6a51b 100644 --- a/Source/animation/AnimationImpl.swift +++ b/Source/animation/AnimationImpl.swift @@ -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 { } open func t(_ duration: Double, delay: Double = 0.0) -> AnimationDescription { - return AnimationDescription(valueFunc: valueFunc, duration: duration, delay: delay) + AnimationDescription(valueFunc: valueFunc, duration: duration, delay: delay) } } diff --git a/Source/animation/AnimationUtils.swift b/Source/animation/AnimationUtils.swift index 71de54b0..e23cdb5b 100644 --- a/Source/animation/AnimationUtils.swift +++ b/Source/animation/AnimationUtils.swift @@ -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 { diff --git a/Source/animation/Easing.swift b/Source/animation/Easing.swift index 77fb16b7..bd813dca 100644 --- a/Source/animation/Easing.swift +++ b/Source/animation/Easing.swift @@ -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)) } } diff --git a/Source/animation/layer_animation/Extensions/AnimOperators.swift b/Source/animation/layer_animation/Extensions/AnimOperators.swift index 202cb07e..a7630939 100644 --- a/Source/animation/layer_animation/Extensions/AnimOperators.swift +++ b/Source/animation/layer_animation/Extensions/AnimOperators.swift @@ -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 diff --git a/Source/animation/layer_animation/Extensions/ContentsInterpolation.swift b/Source/animation/layer_animation/Extensions/ContentsInterpolation.swift index d72e0d71..1e7973d5 100644 --- a/Source/animation/layer_animation/Extensions/ContentsInterpolation.swift +++ b/Source/animation/layer_animation/Extensions/ContentsInterpolation.swift @@ -4,6 +4,6 @@ public protocol ContentsInterpolation: Interpolable { extension Array: ContentsInterpolation { public func interpolate(_ endValue: Array, progress: Double) -> Array { - return self + self } } diff --git a/Source/animation/layer_animation/Extensions/DoubleInterpolation.swift b/Source/animation/layer_animation/Extensions/DoubleInterpolation.swift index 78b287fa..710c2426 100644 --- a/Source/animation/layer_animation/Extensions/DoubleInterpolation.swift +++ b/Source/animation/layer_animation/Extensions/DoubleInterpolation.swift @@ -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 } } diff --git a/Source/animation/layer_animation/Extensions/FillInterpolation.swift b/Source/animation/layer_animation/Extensions/FillInterpolation.swift index d8124665..1de92ca7 100644 --- a/Source/animation/layer_animation/Extensions/FillInterpolation.swift +++ b/Source/animation/layer_animation/Extensions/FillInterpolation.swift @@ -12,6 +12,6 @@ public protocol FillInterpolation: Interpolable { extension Fill: FillInterpolation { public func interpolate(_ endValue: Fill, progress: Double) -> Self { - return self + self } } diff --git a/Source/animation/layer_animation/Extensions/LocusInterpolation.swift b/Source/animation/layer_animation/Extensions/LocusInterpolation.swift index 5646a83f..19e90936 100644 --- a/Source/animation/layer_animation/Extensions/LocusInterpolation.swift +++ b/Source/animation/layer_animation/Extensions/LocusInterpolation.swift @@ -4,6 +4,6 @@ public protocol LocusInterpolation: Interpolable { extension Locus: LocusInterpolation { public func interpolate(_ endValue: Locus, progress: Double) -> Self { - return self + self } } diff --git a/Source/animation/layer_animation/Extensions/ShapeInterpolation.swift b/Source/animation/layer_animation/Extensions/ShapeInterpolation.swift index cc2ab11e..9637a4c3 100644 --- a/Source/animation/layer_animation/Extensions/ShapeInterpolation.swift +++ b/Source/animation/layer_animation/Extensions/ShapeInterpolation.swift @@ -12,6 +12,6 @@ public protocol ShapeInterpolation: Interpolable { extension Shape: ShapeInterpolation { public func interpolate(_ endValue: Shape, progress: Double) -> Self { - return self + self } } diff --git a/Source/animation/layer_animation/Extensions/StrokeInterpolation.swift b/Source/animation/layer_animation/Extensions/StrokeInterpolation.swift index 87f08007..df3cf8b3 100644 --- a/Source/animation/layer_animation/Extensions/StrokeInterpolation.swift +++ b/Source/animation/layer_animation/Extensions/StrokeInterpolation.swift @@ -12,6 +12,6 @@ public protocol StrokeInterpolation: Interpolable { extension Stroke: StrokeInterpolation { public func interpolate(_ endValue: Stroke, progress: Double) -> Self { - return self + self } } diff --git a/Source/animation/layer_animation/Extensions/TransformInterpolation.swift b/Source/animation/layer_animation/Extensions/TransformInterpolation.swift index 9413e550..9f62c42c 100644 --- a/Source/animation/layer_animation/Extensions/TransformInterpolation.swift +++ b/Source/animation/layer_animation/Extensions/TransformInterpolation.swift @@ -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), diff --git a/Source/animation/layer_animation/PathFunctions.swift b/Source/animation/layer_animation/PathFunctions.swift index 6da5f953..b3021b8c 100644 --- a/Source/animation/layer_animation/PathFunctions.swift +++ b/Source/animation/layer_animation/PathFunctions.swift @@ -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)) } diff --git a/Source/animation/types/MorphingAnimation.swift b/Source/animation/types/MorphingAnimation.swift index 70c72f53..84bb206f 100644 --- a/Source/animation/types/MorphingAnimation.swift +++ b/Source/animation/types/MorphingAnimation.swift @@ -2,7 +2,7 @@ class MorphingAnimation: AnimationImpl { 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) } } diff --git a/Source/animation/types/OpacityAnimation.swift b/Source/animation/types/OpacityAnimation.swift index cef432bf..4a66a583 100644 --- a/Source/animation/types/OpacityAnimation.swift +++ b/Source/animation/types/OpacityAnimation.swift @@ -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) } } diff --git a/Source/animation/types/PathAnimation.swift b/Source/animation/types/PathAnimation.swift index 0420d7e0..1d971423 100644 --- a/Source/animation/types/PathAnimation.swift +++ b/Source/animation/types/PathAnimation.swift @@ -51,11 +51,11 @@ public typealias PathAnimationDescription = AnimationDescription open class StrokeAnimatableVariable: AnimatableVariable { 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) } } diff --git a/Source/animation/types/ShapeAnimation.swift b/Source/animation/types/ShapeAnimation.swift index 4a41c24c..a8b42bc8 100644 --- a/Source/animation/types/ShapeAnimation.swift +++ b/Source/animation/types/ShapeAnimation.swift @@ -92,7 +92,7 @@ public extension AnimatableVariable where T == Fill? { finalShape.fill = to _ = ShapeAnimation(animatedNode: shape, finalValue: finalShape, animationDuration: during, delay: delay, autostart: true) } - + func animation(from: Fill? = nil, to: Fill, during: Double = 1.0, delay: Double = 0.0) -> Animation { let shape = node as! Shape shape.fill = from ?? (shape.fill ?? Color.clear) diff --git a/Source/animation/types/TransformAnimation.swift b/Source/animation/types/TransformAnimation.swift index 67bc1f19..fd7152a9 100644 --- a/Source/animation/types/TransformAnimation.swift +++ b/Source/animation/types/TransformAnimation.swift @@ -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) } diff --git a/Source/animation/types/animation_generators/Cache/AnimationCache.swift b/Source/animation/types/animation_generators/Cache/AnimationCache.swift index 0dbcb49b..0f3ff7ac 100644 --- a/Source/animation/types/animation_generators/Cache/AnimationCache.swift +++ b/Source/animation/types/animation_generators/Cache/AnimationCache.swift @@ -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() { diff --git a/Source/animation/types/animation_generators/Cache/NodeHashable.swift b/Source/animation/types/animation_generators/Cache/NodeHashable.swift index ae93ed13..2aa6c225 100644 --- a/Source/animation/types/animation_generators/Cache/NodeHashable.swift +++ b/Source/animation/types/animation_generators/Cache/NodeHashable.swift @@ -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 } diff --git a/Source/animation/types/animation_generators/Cache/TransformHashable.swift b/Source/animation/types/animation_generators/Cache/TransformHashable.swift index fce347c8..36e38ce2 100644 --- a/Source/animation/types/animation_generators/Cache/TransformHashable.swift +++ b/Source/animation/types/animation_generators/Cache/TransformHashable.swift @@ -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 && diff --git a/Source/animation/types/animation_generators/PathAnimationGenerator.swift b/Source/animation/types/animation_generators/PathAnimationGenerator.swift index c7bd052e..5c8f7671 100644 --- a/Source/animation/types/animation_generators/PathAnimationGenerator.swift +++ b/Source/animation/types/animation_generators/PathAnimationGenerator.swift @@ -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 @@ -52,7 +52,7 @@ func addPathAnimation(_ animation: BasicAnimation, _ context: AnimationContext, completion() } - //layer.path = RenderUtils.toCGPath(shape.form).copy(using: &layer.transform) + // layer.path = RenderUtils.toCGPath(shape.form).copy(using: &layer.transform) layer.path = shape.form.toCGPath() layer.setupStrokeAndFill(shape) diff --git a/Source/bindings/Variable.swift b/Source/bindings/Variable.swift index ad71c739..1fbe962d 100644 --- a/Source/bindings/Variable.swift +++ b/Source/bindings/Variable.swift @@ -16,7 +16,7 @@ class ChangeHandler: Equatable { } static func == (lhs: ChangeHandler, rhs: ChangeHandler) -> Bool { - return lhs === rhs + lhs === rhs } } diff --git a/Source/events/TouchEvent.swift b/Source/events/TouchEvent.swift index 3414ffe8..4035aeb1 100644 --- a/Source/events/TouchEvent.swift +++ b/Source/events/TouchEvent.swift @@ -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 diff --git a/Source/layout/ContentLayout.swift b/Source/layout/ContentLayout.swift index 93b5290b..15fb112c 100644 --- a/Source/layout/ContentLayout.swift +++ b/Source/layout/ContentLayout.swift @@ -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 } } diff --git a/Source/model/draw/Align.swift b/Source/model/draw/Align.swift index 2c278597..cc472979 100644 --- a/Source/model/draw/Align.swift +++ b/Source/model/draw/Align.swift @@ -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 } } diff --git a/Source/model/draw/AspectRatio.swift b/Source/model/draw/AspectRatio.swift index d67675c5..da403c18 100644 --- a/Source/model/draw/AspectRatio.swift +++ b/Source/model/draw/AspectRatio.swift @@ -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 } } diff --git a/Source/model/draw/Color.swift b/Source/model/draw/Color.swift index e726e7a4..0bf7df3b 100644 --- a/Source/model/draw/Color.swift +++ b/Source/model/draw/Color.swift @@ -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(other: T) -> Bool where T: Fill { diff --git a/Source/model/draw/Effect.swift b/Source/model/draw/Effect.swift index 7fda78c6..cc38492b 100644 --- a/Source/model/draw/Effect.swift +++ b/Source/model/draw/Effect.swift @@ -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) } } diff --git a/Source/model/draw/Fill.swift b/Source/model/draw/Fill.swift index 3d94ecbd..5d3cee84 100644 --- a/Source/model/draw/Fill.swift +++ b/Source/model/draw/Fill.swift @@ -9,5 +9,5 @@ open class Fill: Equatable { } public func == (lhs: T, rhs: T) -> Bool where T: Fill { - return lhs.equals(other: rhs) + lhs.equals(other: rhs) } diff --git a/Source/model/draw/Stop.swift b/Source/model/draw/Stop.swift index 957e4eec..6c3273c8 100644 --- a/Source/model/draw/Stop.swift +++ b/Source/model/draw/Stop.swift @@ -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 } diff --git a/Source/model/draw/Stroke.swift b/Source/model/draw/Stroke.swift index d2eb6878..c803e542 100644 --- a/Source/model/draw/Stroke.swift +++ b/Source/model/draw/Stroke.swift @@ -20,7 +20,7 @@ open class Stroke: Equatable { } public func == (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 diff --git a/Source/model/geom2d/Arc.swift b/Source/model/geom2d/Arc.swift index 48f303dd..3fccde8a 100644 --- a/Source/model/geom2d/Arc.swift +++ b/Source/model/geom2d/Arc.swift @@ -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, diff --git a/Source/model/geom2d/Circle.swift b/Source/model/geom2d/Circle.swift index 5814a59f..691e5eb9 100644 --- a/Source/model/geom2d/Circle.swift +++ b/Source/model/geom2d/Circle.swift @@ -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(other: T) -> Bool where T: Locus { diff --git a/Source/model/geom2d/Ellipse.swift b/Source/model/geom2d/Ellipse.swift index d9588a85..1fea1043 100644 --- a/Source/model/geom2d/Ellipse.swift +++ b/Source/model/geom2d/Ellipse.swift @@ -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(other: T) -> Bool where T: Locus { diff --git a/Source/model/geom2d/GeomUtils.swift b/Source/model/geom2d/GeomUtils.swift index 82565872..3e05f127 100644 --- a/Source/model/geom2d/GeomUtils.swift +++ b/Source/model/geom2d/GeomUtils.swift @@ -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 { diff --git a/Source/model/geom2d/Line.swift b/Source/model/geom2d/Line.swift index 75ab143e..9ae08d22 100644 --- a/Source/model/geom2d/Line.swift +++ b/Source/model/geom2d/Line.swift @@ -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(other: T) -> Bool where T: Locus { diff --git a/Source/model/geom2d/Locus.swift b/Source/model/geom2d/Locus.swift index e6f9dc56..6053a626 100644 --- a/Source/model/geom2d/Locus.swift +++ b/Source/model/geom2d/Locus.swift @@ -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 == (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) } diff --git a/Source/model/geom2d/Path.swift b/Source/model/geom2d/Path.swift index be171b5a..df8ba2de 100644 --- a/Source/model/geom2d/Path.swift +++ b/Source/model/geom2d/Path.swift @@ -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(other: T) -> Bool where T: Locus { diff --git a/Source/model/geom2d/PathBuilder.swift b/Source/model/geom2d/PathBuilder.swift index d9a11daf..576f0872 100644 --- a/Source/model/geom2d/PathBuilder.swift +++ b/Source/model/geom2d/PathBuilder.swift @@ -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 } } diff --git a/Source/model/geom2d/PathSegment.swift b/Source/model/geom2d/PathSegment.swift index 659c026d..d83c8d79 100644 --- a/Source/model/geom2d/PathSegment.swift +++ b/Source/model/geom2d/PathSegment.swift @@ -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 } } diff --git a/Source/model/geom2d/Point.swift b/Source/model/geom2d/Point.swift index e94412b7..462c250e 100644 --- a/Source/model/geom2d/Point.swift +++ b/Source/model/geom2d/Point.swift @@ -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(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) } } diff --git a/Source/model/geom2d/Rect.swift b/Source/model/geom2d/Rect.swift index 432dbda7..a1abc040 100644 --- a/Source/model/geom2d/Rect.swift +++ b/Source/model/geom2d/Rect.swift @@ -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(other: T) -> Bool where T: Locus { diff --git a/Source/model/geom2d/RoundRect.swift b/Source/model/geom2d/RoundRect.swift index 9bb8e52f..d0c3a101 100644 --- a/Source/model/geom2d/RoundRect.swift +++ b/Source/model/geom2d/RoundRect.swift @@ -11,7 +11,7 @@ open class RoundRect: Locus { } override open func bounds() -> Rect { - return rect + rect } override func equals(other: T) -> Bool where T: Locus { diff --git a/Source/model/geom2d/Size.swift b/Source/model/geom2d/Size.swift index 9f5ef0e6..1b9f824a 100644 --- a/Source/model/geom2d/Size.swift +++ b/Source/model/geom2d/Size.swift @@ -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) } } diff --git a/Source/model/geom2d/Transform.swift b/Source/model/geom2d/Transform.swift index b0e1f217..84209ea2 100644 --- a/Source/model/geom2d/Transform.swift +++ b/Source/model/geom2d/Transform.swift @@ -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 { diff --git a/Source/model/geom2d/TransformedLocus.swift b/Source/model/geom2d/TransformedLocus.swift index 9b2f6720..56587ab9 100644 --- a/Source/model/geom2d/TransformedLocus.swift +++ b/Source/model/geom2d/TransformedLocus.swift @@ -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(other: T) -> Bool where T: Locus { diff --git a/Source/model/scene/Group.swift b/Source/model/scene/Group.swift index 632c47c8..2bcba993 100644 --- a/Source/model/scene/Group.swift +++ b/Source/model/scene/Group.swift @@ -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) } } diff --git a/Source/model/scene/Image.swift b/Source/model/scene/Image.swift index 8f9cbfe9..a040f8d9 100644 --- a/Source/model/scene/Image.swift +++ b/Source/model/scene/Image.swift @@ -10,37 +10,37 @@ open class Image: Node { public let srcVar: Variable open var src: String { - get { return srcVar.value } + get { srcVar.value } set(val) { srcVar.value = val } } public let xAlignVar: Variable open var xAlign: Align { - get { return xAlignVar.value } + get { xAlignVar.value } set(val) { xAlignVar.value = val } } public let yAlignVar: Variable open var yAlign: Align { - get { return yAlignVar.value } + get { yAlignVar.value } set(val) { yAlignVar.value = val } } public let aspectRatioVar: Variable open var aspectRatio: AspectRatio { - get { return aspectRatioVar.value } + get { aspectRatioVar.value } set(val) { aspectRatioVar.value = val } } public let wVar: Variable open var w: Int { - get { return wVar.value } + get { wVar.value } set(val) { wVar.value = val } } public let hVar: Variable open var h: Int { - get { return hVar.value } + get { hVar.value } set(val) { hVar.value = val } } diff --git a/Source/model/scene/Node.swift b/Source/model/scene/Node.swift index d855e0a4..33b0bf2d 100644 --- a/Source/model/scene/Node.swift +++ b/Source/model/scene/Node.swift @@ -4,37 +4,37 @@ open class Node: Drawable { public let placeVar: AnimatableVariable open var place: Transform { - get { return placeVar.value } + get { placeVar.value } set(val) { placeVar.value = val } } public let opaqueVar: Variable open var opaque: Bool { - get { return opaqueVar.value } + get { opaqueVar.value } set(val) { opaqueVar.value = val } } public let opacityVar: AnimatableVariable open var opacity: Double { - get { return opacityVar.value } + get { opacityVar.value } set(val) { opacityVar.value = val } } public let clipVar: Variable open var clip: Locus? { - get { return clipVar.value } + get { clipVar.value } set(val) { clipVar.value = val } } public let maskVar: Variable open var mask: Node? { - get { return maskVar.value } + get { maskVar.value } set(val) { maskVar.value = val } } public let effectVar: Variable 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 diff --git a/Source/model/scene/Shape.swift b/Source/model/scene/Shape.swift index 331bf5d7..32dd627f 100644 --- a/Source/model/scene/Shape.swift +++ b/Source/model/scene/Shape.swift @@ -8,19 +8,19 @@ open class Shape: Node { public let formVar: AnimatableVariable open var form: Locus { - get { return formVar.value } + get { formVar.value } set(val) { formVar.value = val } } public let fillVar: AnimatableVariable 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 } } diff --git a/Source/model/scene/Text.swift b/Source/model/scene/Text.swift index 440225ab..dc9c0931 100644 --- a/Source/model/scene/Text.swift +++ b/Source/model/scene/Text.swift @@ -8,43 +8,43 @@ open class Text: Node { public let textVar: Variable open var text: String { - get { return textVar.value } + get { textVar.value } set(val) { textVar.value = val } } public let fontVar: Variable open var font: Font? { - get { return fontVar.value } + get { fontVar.value } set(val) { fontVar.value = val } } public let fillVar: Variable open var fill: Fill? { - get { return fillVar.value } + get { fillVar.value } set(val) { fillVar.value = val } } public let strokeVar: Variable open var stroke: Stroke? { - get { return strokeVar.value } + get { strokeVar.value } set(val) { strokeVar.value = val } } public let alignVar: Variable open var align: Align { - get { return alignVar.value } + get { alignVar.value } set(val) { alignVar.value = val } } public let baselineVar: Variable open var baseline: Baseline { - get { return baselineVar.value } + get { baselineVar.value } set(val) { baselineVar.value = val } } public let kerningVar: Variable open var kerning: Float { - get { return kerningVar.value } + get { kerningVar.value } set(val) { kerningVar.value = val } } diff --git a/Source/platform/iOS/Common_iOS.swift b/Source/platform/iOS/Common_iOS.swift index 3a25ac25..264d8420 100644 --- a/Source/platform/iOS/Common_iOS.swift +++ b/Source/platform/iOS/Common_iOS.swift @@ -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 } } diff --git a/Source/platform/iOS/Graphics_iOS.swift b/Source/platform/iOS/Graphics_iOS.swift index 52a04aa7..588b125f 100644 --- a/Source/platform/iOS/Graphics_iOS.swift +++ b/Source/platform/iOS/Graphics_iOS.swift @@ -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 diff --git a/Source/platform/iOS/MView_iOS.swift b/Source/platform/iOS/MView_iOS.swift index 61d8d32e..ae60be49 100644 --- a/Source/platform/iOS/MView_iOS.swift +++ b/Source/platform/iOS/MView_iOS.swift @@ -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() { diff --git a/Source/platform/macOS/Common_macOS.swift b/Source/platform/macOS/Common_macOS.swift index f667c3e8..4731714f 100644 --- a/Source/platform/macOS/Common_macOS.swift +++ b/Source/platform/macOS/Common_macOS.swift @@ -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 } } diff --git a/Source/platform/macOS/Graphics_macOS.swift b/Source/platform/macOS/Graphics_macOS.swift index c0b9d913..e0ab93da 100644 --- a/Source/platform/macOS/Graphics_macOS.swift +++ b/Source/platform/macOS/Graphics_macOS.swift @@ -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 diff --git a/Source/platform/macOS/MBezierPath+Extension_macOS.swift b/Source/platform/macOS/MBezierPath+Extension_macOS.swift index e38dbf29..548ca1e8 100644 --- a/Source/platform/macOS/MBezierPath+Extension_macOS.swift +++ b/Source/platform/macOS/MBezierPath+Extension_macOS.swift @@ -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) { diff --git a/Source/platform/macOS/MView_macOS.swift b/Source/platform/macOS/MView_macOS.swift index 469d36b4..2425fb3e 100644 --- a/Source/platform/macOS/MView_macOS.swift +++ b/Source/platform/macOS/MView_macOS.swift @@ -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 diff --git a/Source/render/GroupRenderer.swift b/Source/render/GroupRenderer.swift index 36f3d3ed..01a29a1b 100644 --- a/Source/render/GroupRenderer.swift +++ b/Source/render/GroupRenderer.swift @@ -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) { diff --git a/Source/render/ImageRenderer.swift b/Source/render/ImageRenderer.swift index 0f1b7667..037bd8f6 100644 --- a/Source/render/ImageRenderer.swift +++ b/Source/render/ImageRenderer.swift @@ -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) { diff --git a/Source/render/NodeRenderer.swift b/Source/render/NodeRenderer.swift index 6b12443b..84af8f89 100644 --- a/Source/render/NodeRenderer.swift +++ b/Source/render/NodeRenderer.swift @@ -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 @@ -218,7 +218,7 @@ class NodeRenderer { guard let shapeCGImage = renderToImage(bounds: bounds, inset: inset, coloringMode: coloringMode)?.cgImage else { return } - + let shapeImage = CIImage(cgImage: shapeCGImage) var filteredImage = shapeImage for effect in effects { @@ -312,7 +312,7 @@ class NodeRenderer { } public func doFindNodeAt(path: NodePath, ctx: CGContext) -> NodePath? { - return nil + nil } func calculateZPositionRecursively() { diff --git a/Source/render/RenderUtils.swift b/Source/render/RenderUtils.swift index fe6b3d01..36650639 100644 --- a/Source/render/RenderUtils.swift +++ b/Source/render/RenderUtils.swift @@ -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?) { diff --git a/Source/render/ShapeRenderer.swift b/Source/render/ShapeRenderer.swift index ebcc5d08..bdc85069 100644 --- a/Source/render/ShapeRenderer.swift +++ b/Source/render/ShapeRenderer.swift @@ -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 { diff --git a/Source/render/TextRenderer.swift b/Source/render/TextRenderer.swift index c34d373c..ec251249 100644 --- a/Source/render/TextRenderer.swift +++ b/Source/render/TextRenderer.swift @@ -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) { diff --git a/Source/svg/SVGConstants.swift b/Source/svg/SVGConstants.swift index 5111644d..8c262979 100644 --- a/Source/svg/SVGConstants.swift +++ b/Source/svg/SVGConstants.swift @@ -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 diff --git a/Source/svg/SVGNodeLayout.swift b/Source/svg/SVGNodeLayout.swift index 75ab7c9a..25511fbe 100644 --- a/Source/svg/SVGNodeLayout.swift +++ b/Source/svg/SVGNodeLayout.swift @@ -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) { diff --git a/Source/svg/SVGParser.swift b/Source/svg/SVGParser.swift index 58bf22c6..12865da8 100644 --- a/Source/svg/SVGParser.swift +++ b/Source/svg/SVGParser.swift @@ -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", @@ -470,8 +470,8 @@ open class SVGParser { if pattern.children.isEmpty { return parentPattern?.content } else if pattern.children.count == 1, - let child = pattern.children.first, - let shape = try parseNode(child) as? Shape { + let child = pattern.children.first, + let shape = try parseNode(child) as? Shape { return shape } else { var shapes = [Shape]() @@ -876,7 +876,7 @@ open class SVGParser { return dashes } - fileprivate func getMatrix(_ element: XMLHash.XMLElement, attribute: String) -> [Double] { + fileprivate func getMatrix(_ element: XMLHash.XMLElement, attribute: String) -> [Double] { var result = [Double]() if let values = element.allAttributes[attribute]?.text { let separatedValues = values.components(separatedBy: CharacterSet(charactersIn: " ,")) @@ -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 } } @@ -2248,7 +2248,7 @@ fileprivate extension Scanner { return scanUpTo(substring, into: &string) ? string as String? : nil } } - + /// A version of `scanString(_:)`, available for an earlier OS. func scannedString(_ searchString: String) -> String? { if #available(OSX 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) { diff --git a/Source/svg/SVGSerializer.swift b/Source/svg/SVGSerializer.swift index 096abbe1..d9a74d96 100644 --- a/Source/svg/SVGSerializer.swift +++ b/Source/svg/SVGSerializer.swift @@ -54,7 +54,7 @@ open class SVGSerializer { fileprivate let SVGEpsilon: Double = 0.00001 fileprivate let SVGDefaultOpacityValueAsAlpha = 1 * 255 - fileprivate func tag(_ tag: String, _ args: [String: String]=[:], close: Bool = false) -> String { + fileprivate func tag(_ tag: String, _ args: [String: String] = [:], close: Bool = false) -> String { let attrs = args.sorted { a1, a2 -> Bool in a1.key < a2.key } .map { "\($0)=\"\($1)\"" }.joined(separator: " ") let closeTag = close ? " />" : "" @@ -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) } } diff --git a/Source/thirdparty/CAAnimationClosure.swift b/Source/thirdparty/CAAnimationClosure.swift index 800c0a58..dabf060c 100644 --- a/Source/thirdparty/CAAnimationClosure.swift +++ b/Source/thirdparty/CAAnimationClosure.swift @@ -139,7 +139,7 @@ public extension CAAnimation { } get { - return animating + animating } } } diff --git a/Source/thirdparty/CGFloat+Double.swift b/Source/thirdparty/CGFloat+Double.swift index 5ee15176..44cf271b 100644 --- a/Source/thirdparty/CGFloat+Double.swift +++ b/Source/thirdparty/CGFloat+Double.swift @@ -7,6 +7,6 @@ import UIKit internal extension CGFloat { var doubleValue: Double { - return Double(self) + Double(self) } } diff --git a/Source/utils/CGMappings.swift b/Source/utils/CGMappings.swift index d2f247f7..fe4b35ef 100644 --- a/Source/utils/CGMappings.swift +++ b/Source/utils/CGMappings.swift @@ -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)) } } @@ -146,7 +146,7 @@ public extension Node { let transform = LayoutHelper.calcTransform(self, layout, size) ctx.concatenate(transform.toCG()) renderer.render(in: ctx, force: false, opacity: self.opacity) - + defer { MGraphicsEndImageContext() renderer.dispose() diff --git a/Source/utils/DescriptionExtensions.swift b/Source/utils/DescriptionExtensions.swift index 95aebc33..4766a795 100644 --- a/Source/utils/DescriptionExtensions.swift +++ b/Source/utils/DescriptionExtensions.swift @@ -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))" } } diff --git a/Source/views/MacawView.swift b/Source/views/MacawView.swift index cb1ae1e1..2e379215 100644 --- a/Source/views/MacawView.swift +++ b/Source/views/MacawView.swift @@ -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 { - 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) -> [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 { - return placeManager.placeVar + placeManager.placeVar } override open var frame: CGRect { diff --git a/Source/views/MacawZoom.swift b/Source/views/MacawZoom.swift index bf162452..afa69d72 100644 --- a/Source/views/MacawZoom.swift +++ b/Source/views/MacawZoom.swift @@ -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() } } diff --git a/Source/views/Touchable.swift b/Source/views/Touchable.swift index f5229470..0c3c1170 100644 --- a/Source/views/Touchable.swift +++ b/Source/views/Touchable.swift @@ -14,7 +14,7 @@ class MTouchEvent: Hashable { } public static func == (lhs: MTouchEvent, rhs: MTouchEvent) -> Bool { - return lhs.id == rhs.id + lhs.id == rhs.id } }