1// TODO: Unite UIView and CALayer extensions under a common protocol
5func - (left: CGPoint, right: CGPoint) -> CGVector {
6 return CGVector(dx: left.x - right.x, dy: left.y - right.y)
9func * (left: CGVector, right: CGVector) -> CGFloat {
10 return (left.dx * right.dx) + (left.dy * right.dy)
13func / (vector: CGVector, scalar: CGFloat) -> CGVector {
14 return CGVector(dx: vector.dx / scalar, dy: vector.dy / scalar)
25 var normalized: CGVector {
31 mutating func normalize() {
39extension CGFloat: DoubleValuable {
40 var toDouble: Double { get {
45 static func fromDouble(_ double: Double) -> CGFloat {
46 return CGFloat(double)
51extension CGFloat: Numeric {}
74 init(_ squareSize: CGFloat) {
75 self.init(width: squareSize, height: squareSize)
85 frame.origin = newValue
103 frame.size = CGSize(width: newValue, height: height)
107 var height: CGFloat {
112 frame.size = CGSize(width: width, height: newValue)
116 var middle: CGPoint {
118 return CGPoint(x: origin.x + width / 2, y: origin.y + height / 2)
121 origin = CGPoint(x: newValue.x - width / 2, y: newValue.y - height / 2)
130 middle = CGPoint(x: newValue, y: midY)
139 middle = CGPoint(x: midX, y: newValue)
145 var origin: CGPoint {
150 frame.origin = newValue
159 frame.size = newValue
168 frame.size = CGSize(width: newValue, height: height)
172 var height: CGFloat {
177 frame.size = CGSize(width: width, height: newValue)
181 var middle: CGPoint {
183 return CGPoint(x: origin.x + width / 2, y: origin.y + height / 2)
186 origin = CGPoint(x: newValue.x - width / 2, y: newValue.y - height / 2)
195 middle = CGPoint(x: newValue, y: midY)
204 middle = CGPoint(x: midX, y: newValue)
209let screenRect = UIScreen.main.bounds
210let screenWidth = screenRect.size.width
211let screenHeight = screenRect.size.height
213func * <T: Numeric>(vector: CGVector, scalar: T) -> CGVector {
214 return CGVector(dx: vector.dx * CGFloat(scalar.toDouble), dy: vector.dy * CGFloat(scalar.toDouble))
217func + (point: CGPoint, vector: CGVector) -> CGPoint {
218 return CGPoint(x: point.x + vector.dx, y: point.y + vector.dy)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list