BooleanPath for macOS
像 Adobe Illustrator 的路径查找器一样,向 NSBezierPath 添加布尔运算。
关于 BooleanPath
这是对由 Leslie Titze 编写的 VectorBoolean 的重写。
BooleanPath 用 Swift 为 macOS 编写。
安装
CocoaPods
pod 'BooleanPath'
Carthage
github "Kyome22/BooleanPath"
演示
示例代码位于项目之中。
使用示例
import Cocoa
import BooleanPath
let rectPath = NSBezierPath(rect: NSRect(x: 10, y: 30, width: 60, height: 60))
let circlePath = NSBezierPath(ovalIn: NSRect(x: 25, y: 15, width: 50, height: 50))
// Union
let unionPath: NSBezierPath = rectPath.union(circlePath)
unionPath.fill()
// Intersection
let intersectionPath: NSBezierPath = rectPath.intersection(circlePath)
intersectionPath.fill()
// Subtraction
let subtractionPath: NSBezierPath = rectPath.subtraction(circlePath)
subtractionPath.fill()
// Difference
let differencePath: NSBezierPath = rectPath.difference(circlePath)
differencePath.fill()