File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed
Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,16 @@ import CoreGraphics
33public extension CGPoint {
44 static var zero : Self { Self ( x: 0 , y: 0 ) }
55
6+ init ( _ vector: CGVector ) {
7+ x = vector. dx
8+ y = vector. dy
9+ }
10+
11+ init ( _ size: CGSize ) {
12+ x = size. width
13+ y = size. height
14+ }
15+
616 // MARK: Point × Vector
717
818 static func + ( point: Self , offset: CGVector ) -> Self {
Original file line number Diff line number Diff line change @@ -5,6 +5,16 @@ public extension CGSize {
55
66 static var one : CGSize { . init( width: 1 , height: 1 ) }
77
8+ init ( _ point: CGPoint ) {
9+ width = point. x
10+ height = point. y
11+ }
12+
13+ init ( _ vector: CGVector ) {
14+ width = vector. dx
15+ height = vector. dy
16+ }
17+
818 // MARK: Size × Float
919
1020 static func * ( size: Self , scale: CGFloat ) -> Self {
Original file line number Diff line number Diff line change @@ -11,6 +11,16 @@ public extension CGVector {
1111 self . init ( dx: cos ( angle) * length, dy: sin ( angle) * length)
1212 }
1313
14+ init ( _ point: CGPoint ) {
15+ dx = point. x
16+ dy = point. y
17+ }
18+
19+ init ( _ size: CGSize ) {
20+ dx = size. width
21+ dy = size. height
22+ }
23+
1424 func clamped( to length: CGFloat ) -> Self {
1525 let len = self . length
1626
You can’t perform that action at this time.
0 commit comments