diff --git a/Swift VectorBoolean.xcodeproj/project.pbxproj b/Swift VectorBoolean.xcodeproj/project.pbxproj index bae5bae..fbd0891 100644 --- a/Swift VectorBoolean.xcodeproj/project.pbxproj +++ b/Swift VectorBoolean.xcodeproj/project.pbxproj @@ -180,7 +180,9 @@ C90815DD1DE63B0F00D4655A /* VectorBoolean */, 6356E1791B4CD83A00420351 /* Products */, ); + indentWidth = 2; sourceTree = ""; + tabWidth = 2; }; 6356E1791B4CD83A00420351 /* Products */ = { isa = PBXGroup; @@ -341,9 +343,8 @@ TargetAttributes = { 6356E1771B4CD83A00420351 = { CreatedOnToolsVersion = 6.4; - DevelopmentTeam = ZBQGXUCEGE; LastSwiftMigration = 0800; - ProvisioningStyle = Automatic; + ProvisioningStyle = Manual; }; 6356E18C1B4CD83A00420351 = { CreatedOnToolsVersion = 6.4; @@ -353,8 +354,7 @@ }; C90815DB1DE63B0F00D4655A = { CreatedOnToolsVersion = 8.1; - DevelopmentTeam = 579VCLF427; - ProvisioningStyle = Automatic; + ProvisioningStyle = Manual; }; }; }; @@ -363,6 +363,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -613,13 +614,15 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = ZBQGXUCEGE; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "Swift VectorBoolean/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.starside.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -629,11 +632,14 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = ZBQGXUCEGE; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "Swift VectorBoolean/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.starside.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -677,10 +683,11 @@ CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_SUSPICIOUS_MOVES = YES; CODE_SIGN_IDENTITY = ""; + CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = dwarf; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 579VCLF427; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -689,9 +696,10 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.moke.VectorBoolean; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -705,9 +713,10 @@ CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_SUSPICIOUS_MOVES = YES; CODE_SIGN_IDENTITY = ""; + CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 579VCLF427; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -716,8 +725,9 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.moke.VectorBoolean; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; diff --git a/Swift VectorBoolean/OptionsViewController.swift b/Swift VectorBoolean/OptionsViewController.swift index 0c00719..09ee83d 100644 --- a/Swift VectorBoolean/OptionsViewController.swift +++ b/Swift VectorBoolean/OptionsViewController.swift @@ -60,7 +60,7 @@ class OptionsViewController: UIViewController { } } - func dismissVC() { + @objc func dismissVC() { self.dismiss(animated: true) { self.primeVC?.popClosed() } diff --git a/Swift VectorBoolean/ShapesTableViewController.swift b/Swift VectorBoolean/ShapesTableViewController.swift index 64d65a0..f88394d 100644 --- a/Swift VectorBoolean/ShapesTableViewController.swift +++ b/Swift VectorBoolean/ShapesTableViewController.swift @@ -44,7 +44,7 @@ class ShapesTableViewController: UITableViewController { } - func dismissVC() { + @objc func dismissVC() { self.dismiss(animated: true) { self.primeVC?.popClosed() } diff --git a/Swift VectorBoolean/VectorBoolean/BezierExtensions/UIBezierPath_Boolean.swift b/Swift VectorBoolean/VectorBoolean/BezierExtensions/UIBezierPath_Boolean.swift index 79e3eb4..32cf0eb 100644 --- a/Swift VectorBoolean/VectorBoolean/BezierExtensions/UIBezierPath_Boolean.swift +++ b/Swift VectorBoolean/VectorBoolean/BezierExtensions/UIBezierPath_Boolean.swift @@ -14,7 +14,7 @@ public extension UIBezierPath { // 15 //- (NSBezierPath *) fb_union:(NSBezierPath *)path - func fb_union(_ path: UIBezierPath) -> UIBezierPath { + @objc func fb_union(_ path: UIBezierPath) -> UIBezierPath { let thisGraph = FBBezierGraph(path: self) let otherGraph = FBBezierGraph(path: path) let resultGraph = thisGraph.unionWithBezierGraph(otherGraph)! @@ -25,7 +25,7 @@ public extension UIBezierPath { // 24 //- (NSBezierPath *) fb_intersect:(NSBezierPath *)path - func fb_intersect(_ path: UIBezierPath) -> UIBezierPath { + @objc func fb_intersect(_ path: UIBezierPath) -> UIBezierPath { let thisGraph = FBBezierGraph(path: self) let otherGraph = FBBezierGraph(path: path) let result = thisGraph.intersectWithBezierGraph(otherGraph).bezierPath @@ -35,7 +35,7 @@ public extension UIBezierPath { // 33 //- (NSBezierPath *) fb_difference:(NSBezierPath *)path - func fb_difference(_ path: UIBezierPath) -> UIBezierPath { + @objc func fb_difference(_ path: UIBezierPath) -> UIBezierPath { let thisGraph = FBBezierGraph(path: self) let otherGraph = FBBezierGraph(path: path) let result = thisGraph.differenceWithBezierGraph(otherGraph).bezierPath @@ -45,12 +45,20 @@ public extension UIBezierPath { // 42 //- (NSBezierPath *) fb_xor:(NSBezierPath *)path - func fb_xor(_ path: UIBezierPath) -> UIBezierPath { - let thisGraph = FBBezierGraph(path: self) - let otherGraph = FBBezierGraph(path: path) - let result = thisGraph.xorWithBezierGraph(otherGraph).bezierPath - result.fb_copyAttributesFrom(self) - return result + /// TODO: xorWithBezierGraph has bugs with circle and rectangle. Temporarily replaced by mutual difference + @objc func fb_xor(_ path: UIBezierPath) -> UIBezierPath { + + + // let thisGraph = FBBezierGraph(path: self) + // let otherGraph = FBBezierGraph(path: path) + // let result = thisGraph.xorWithBezierGraph(otherGraph).bezierPath + // result.fb_copyAttributesFrom(self) + // return result + + let pathA = self.fb_difference(path) + let pathB = path.fb_difference(self) + pathA.append(pathB) + return pathA } } diff --git a/Swift VectorBoolean/VectorBoolean/CGPathBridge/CGPath.swift b/Swift VectorBoolean/VectorBoolean/CGPathBridge/CGPath.swift index 7d6e3e3..23fdfb6 100644 --- a/Swift VectorBoolean/VectorBoolean/CGPathBridge/CGPath.swift +++ b/Swift VectorBoolean/VectorBoolean/CGPathBridge/CGPath.swift @@ -13,7 +13,7 @@ typealias MyPathApplier = @convention(block) (UnsafePointer) -> V // if you don't, you get "fatal error: can't unsafeBitCast between // types of different sizes" at runtime, on Mac OS X at least. -private func myPathApply(_ path: CGPath!, block: MyPathApplier) { +private func myPathApply(_ path: CGPath!, block: @escaping MyPathApplier) { let callback: @convention(c) (UnsafeMutableRawPointer, UnsafePointer) -> Void = { (info, element) in let block = unsafeBitCast(info, to: MyPathApplier.self) block(element) @@ -32,7 +32,7 @@ public enum PathElement { public extension CGPath { - func apply(_ fn: (PathElement) -> Void) { + func apply(_ fn: @escaping (PathElement) -> Void) { myPathApply(self) { element in let points = element.pointee.points switch (element.pointee.type) { diff --git a/Swift VectorBoolean/VectorBoolean/FBBezierCurve.swift b/Swift VectorBoolean/VectorBoolean/FBBezierCurve.swift index 517a202..3b3feaa 100644 --- a/Swift VectorBoolean/VectorBoolean/FBBezierCurve.swift +++ b/Swift VectorBoolean/VectorBoolean/FBBezierCurve.swift @@ -939,7 +939,7 @@ class FBBezierCurveData { //static void FBBezierCurveDataConvertSelfAndPoint(FBBezierCurveData me, NSPoint point, NSPoint *bezierPoints) func convertSelfAndPoint(_ point: CGPoint) -> [CGPoint] { - var selfPoints: [CGPoint] = [endPoint1, controlPoint1, controlPoint2, endPoint2] + let selfPoints: [CGPoint] = [endPoint1, controlPoint1, controlPoint2, endPoint2] // c[i] in the paper let distanceFromPoint = [ @@ -1453,7 +1453,7 @@ private func pfRefineParameter(_ me: FBBezierCurveData, parameter: Double, point // f'(parameter) = (Q(parameter) - point) * Q''(parameter) + Q'(parameter) * Q'(parameter) // - var bezierPoints: [CGPoint] = [me.endPoint1, me.controlPoint1, me.controlPoint2, me.endPoint2] + let bezierPoints: [CGPoint] = [me.endPoint1, me.controlPoint1, me.controlPoint2, me.endPoint2] // Compute Q(parameter) let qAtParameter = BezierWithPoints(3, bezierPoints: bezierPoints, parameter: parameter, withCurves: false).point