Skip to content

Commit 050239b

Browse files
authored
Add CGVector type (#7)
1 parent a36ba82 commit 050239b

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// CGVector.swift
3+
// OpenCoreGraphics
4+
5+
public import Foundation
6+
7+
// MARK: - CGVector
8+
9+
public struct CGVector: Equatable, Sendable {
10+
public init() {
11+
dx = .zero
12+
dy = .zero
13+
}
14+
15+
public init(dx: CGFloat, dy: CGFloat) {
16+
self.dx = dx
17+
self.dy = dy
18+
}
19+
20+
public var dx: CGFloat
21+
public var dy: CGFloat
22+
23+
public static let zero = CGVector()
24+
}
25+
26+
// MARK: - Hashable
27+
28+
extension CGVector: Swift.Hashable {
29+
public func hash(into hasher: inout Hasher) {
30+
hasher.combine(dx)
31+
hasher.combine(dy)
32+
}
33+
}
34+
35+
// MARK: - CustomDebugStringConvertible
36+
37+
extension CGVector: Swift.CustomDebugStringConvertible {
38+
public var debugDescription: String {
39+
"(\(dx.description), \(dy.description))"
40+
}
41+
}

0 commit comments

Comments
 (0)