Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions Swift VectorBoolean.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@
C90815DD1DE63B0F00D4655A /* VectorBoolean */,
6356E1791B4CD83A00420351 /* Products */,
);
indentWidth = 2;
sourceTree = "<group>";
tabWidth = 2;
};
6356E1791B4CD83A00420351 /* Products */ = {
isa = PBXGroup;
Expand Down Expand Up @@ -341,9 +343,8 @@
TargetAttributes = {
6356E1771B4CD83A00420351 = {
CreatedOnToolsVersion = 6.4;
DevelopmentTeam = ZBQGXUCEGE;
LastSwiftMigration = 0800;
ProvisioningStyle = Automatic;
ProvisioningStyle = Manual;
};
6356E18C1B4CD83A00420351 = {
CreatedOnToolsVersion = 6.4;
Expand All @@ -353,8 +354,7 @@
};
C90815DB1DE63B0F00D4655A = {
CreatedOnToolsVersion = 8.1;
DevelopmentTeam = 579VCLF427;
ProvisioningStyle = Automatic;
ProvisioningStyle = Manual;
};
};
};
Expand All @@ -363,6 +363,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand Down Expand Up @@ -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";
Expand All @@ -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 = "";
};
Expand All @@ -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";
Expand All @@ -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 = "";
};
Expand Down
2 changes: 1 addition & 1 deletion Swift VectorBoolean/OptionsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class OptionsViewController: UIViewController {
}
}

func dismissVC() {
@objc func dismissVC() {
self.dismiss(animated: true) {
self.primeVC?.popClosed()
}
Expand Down
2 changes: 1 addition & 1 deletion Swift VectorBoolean/ShapesTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ShapesTableViewController: UITableViewController {
}


func dismissVC() {
@objc func dismissVC() {
self.dismiss(animated: true) {
self.primeVC?.popClosed()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)!
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
}

}
4 changes: 2 additions & 2 deletions Swift VectorBoolean/VectorBoolean/CGPathBridge/CGPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ typealias MyPathApplier = @convention(block) (UnsafePointer<CGPathElement>) -> 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<CGPathElement>) -> Void = { (info, element) in
let block = unsafeBitCast(info, to: MyPathApplier.self)
block(element)
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions Swift VectorBoolean/VectorBoolean/FBBezierCurve.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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
Expand Down