Skip to content
This repository was archived by the owner on Apr 16, 2022. It is now read-only.

Commit 2a86a7f

Browse files
authored
Merge pull request #103 from natmark/natmark/gestures
Support gesture events
2 parents 8ebe20c + e37f00d commit 2a86a7f

File tree

14 files changed

+877
-519
lines changed

14 files changed

+877
-519
lines changed

ProcessingKit.xcodeproj/project.pbxproj

Lines changed: 36 additions & 20 deletions
Large diffs are not rendered by default.

ProcessingKit/Core/Context/Context.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public typealias UIFont = NSFont
2121
public typealias UIEvent = NSEvent
2222
public typealias UIView = NSView
2323
public typealias UIResponder = NSResponder
24+
public typealias CGRect = NSRect
25+
public typealias CGPoint = NSPoint
2426
#endif
2527

2628
public protocol ContextComponenetsContract {

ProcessingKit/Core/Extensions/CGPoint.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,23 @@
1010
import UIKit
1111
#elseif os(OSX)
1212
import Cocoa
13-
public typealias CGPoint = NSPoint
1413
#endif
1514

15+
extension CGPoint: Hashable {
16+
func distance(point: CGPoint) -> Float {
17+
let dx = Float(x - point.x)
18+
let dy = Float(y - point.y)
19+
return sqrt((dx * dx) + (dy * dy))
20+
}
21+
public var hashValue: Int {
22+
return x.hashValue << 32 ^ y.hashValue
23+
}
24+
}
25+
26+
func == (lhs: CGPoint, rhs: CGPoint) -> Bool {
27+
return lhs.distance(point: rhs) < 0.000001
28+
}
29+
1630
extension CGPoint {
1731
func addTo(_ a: CGPoint) -> CGPoint {
1832
return CGPoint(x: self.x + a.x, y: self.y + a.y)

ProcessingKit/Core/Input/Event.swift

Lines changed: 0 additions & 216 deletions
This file was deleted.

0 commit comments

Comments
 (0)