Skip to content

Commit 7eb58dd

Browse files
author
Alejandro Isaza
committed
Merge branch '1.1.x'
2 parents e420e99 + a224668 commit 7eb58dd

File tree

101 files changed

+2037
-1445
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+2037
-1445
lines changed

Diff for: C4/Core/C4Color.swift renamed to C4/Core/Color.swift

+69-69
Original file line numberDiff line numberDiff line change
@@ -20,67 +20,67 @@
2020
import UIKit
2121
import CoreGraphics
2222

23-
/// A C4Color object whose RGB value is 0, 0, 0 and whose alpha value is 1.0.
24-
public let black = C4Color(red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0)
25-
/// A C4Color object whose RGB value is 0.33, 0.33, 0.33 and whose alpha value is 1.0.
26-
public let darkGray = C4Color(red: 1.0/3.0, green: 1.0/3.0, blue: 1.0/3.0, alpha: 1.0)
27-
/// A C4Color object whose RGB value is 0.66, 0.66, 0.66 and whose alpha value is 1.0.
28-
public let lightGray = C4Color(red: 2.0/3.0, green: 2.0/3.0, blue: 2.0/3.0, alpha: 1.0)
29-
/// A C4Color object whose RGB value is 1.0, 1.0, 1.0 and whose alpha value is 1.0.
30-
public let white = C4Color(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
31-
/// A C4Color object whose RGB value is 0.5, 0.5, 0.5 and whose alpha value is 1.0.
32-
public let gray = C4Color(red: 0.5, green: 0.5, blue: 0.5, alpha: 1.0)
33-
/// A C4Color object whose RGB value is 1.0, 0.0, 0.0 and whose alpha value is 1.0.
34-
public let red = C4Color(red: 1.0, green: 0.0, blue: 0.0, alpha: 1.0)
35-
/// A C4Color object whose RGB value is 0.0, 1.0, 0.0 and whose alpha value is 1.0.
36-
public let green = C4Color(red: 0.0, green: 1.0, blue: 0.0, alpha: 1.0)
37-
/// A C4Color object whose RGB value is 0.0, 0.0, 1.0 and whose alpha value is 1.0.
38-
public let blue = C4Color(red: 0.0, green: 0.0, blue: 1.0, alpha: 1.0)
39-
/// A C4Color object whose RGB value is 0.0, 1.0, 1.0 and whose alpha value is 1.0.
40-
public let cyan = C4Color(red: 0.0, green: 1.0, blue: 1.0, alpha: 1.0)
41-
/// A C4Color object whose RGB value is 1.0, 1.0, 0.0 and whose alpha value is 1.0.
42-
public let yellow = C4Color(red: 1.0, green: 1.0, blue: 0.0, alpha: 1.0)
43-
/// A C4Color object whose RGB value is 1.0, 0.0, 1.0 and whose alpha value is 1.0.
44-
public let magenta = C4Color(red: 1.0, green: 0.0, blue: 1.0, alpha: 1.0)
45-
/// A C4Color object whose RGB value is 1.0, 0.5, 0.0 and whose alpha value is 1.0.
46-
public let orange = C4Color(red: 1.0, green: 0.5, blue: 0.0, alpha: 1.0)
47-
/// A C4Color object whose RGB value is 0.5, 0.0, 0.5 and whose alpha value is 1.0.
48-
public let purple = C4Color(red: 0.5, green: 0.0, blue: 0.5, alpha: 1.0)
49-
/// A C4Color object whose RGB value is 0.6, 0.4, 0.2 and whose alpha value is 1.0.
50-
public let brown = C4Color(red: 0.6, green: 0.4, blue: 0.2, alpha: 1.0)
51-
/// A C4Color object whose RGB value is 0.0, 0.0, 0.0 and whose alpha value is 0.0.
52-
public let clear = C4Color(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0)
23+
/// A Color object whose RGB value is 0, 0, 0 and whose alpha value is 1.0.
24+
public let black = Color(red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0)
25+
/// A Color object whose RGB value is 0.33, 0.33, 0.33 and whose alpha value is 1.0.
26+
public let darkGray = Color(red: 1.0/3.0, green: 1.0/3.0, blue: 1.0/3.0, alpha: 1.0)
27+
/// A Color object whose RGB value is 0.66, 0.66, 0.66 and whose alpha value is 1.0.
28+
public let lightGray = Color(red: 2.0/3.0, green: 2.0/3.0, blue: 2.0/3.0, alpha: 1.0)
29+
/// A Color object whose RGB value is 1.0, 1.0, 1.0 and whose alpha value is 1.0.
30+
public let white = Color(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
31+
/// A Color object whose RGB value is 0.5, 0.5, 0.5 and whose alpha value is 1.0.
32+
public let gray = Color(red: 0.5, green: 0.5, blue: 0.5, alpha: 1.0)
33+
/// A Color object whose RGB value is 1.0, 0.0, 0.0 and whose alpha value is 1.0.
34+
public let red = Color(red: 1.0, green: 0.0, blue: 0.0, alpha: 1.0)
35+
/// A Color object whose RGB value is 0.0, 1.0, 0.0 and whose alpha value is 1.0.
36+
public let green = Color(red: 0.0, green: 1.0, blue: 0.0, alpha: 1.0)
37+
/// A Color object whose RGB value is 0.0, 0.0, 1.0 and whose alpha value is 1.0.
38+
public let blue = Color(red: 0.0, green: 0.0, blue: 1.0, alpha: 1.0)
39+
/// A Color object whose RGB value is 0.0, 1.0, 1.0 and whose alpha value is 1.0.
40+
public let cyan = Color(red: 0.0, green: 1.0, blue: 1.0, alpha: 1.0)
41+
/// A Color object whose RGB value is 1.0, 1.0, 0.0 and whose alpha value is 1.0.
42+
public let yellow = Color(red: 1.0, green: 1.0, blue: 0.0, alpha: 1.0)
43+
/// A Color object whose RGB value is 1.0, 0.0, 1.0 and whose alpha value is 1.0.
44+
public let magenta = Color(red: 1.0, green: 0.0, blue: 1.0, alpha: 1.0)
45+
/// A Color object whose RGB value is 1.0, 0.5, 0.0 and whose alpha value is 1.0.
46+
public let orange = Color(red: 1.0, green: 0.5, blue: 0.0, alpha: 1.0)
47+
/// A Color object whose RGB value is 0.5, 0.0, 0.5 and whose alpha value is 1.0.
48+
public let purple = Color(red: 0.5, green: 0.0, blue: 0.5, alpha: 1.0)
49+
/// A Color object whose RGB value is 0.6, 0.4, 0.2 and whose alpha value is 1.0.
50+
public let brown = Color(red: 0.6, green: 0.4, blue: 0.2, alpha: 1.0)
51+
/// A Color object whose RGB value is 0.0, 0.0, 0.0 and whose alpha value is 0.0.
52+
public let clear = Color(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0)
5353

54-
///A C4Color object whose RGB value is 1.0, 0.0, 0.475 and whose alpha value is 1.0.
55-
public let C4Pink = C4Color(red: 1.0, green: 0.0, blue: 0.475, alpha: 1.0)
56-
///A C4Color object whose RGB value is 0.098, 0.271, 1.0 and whose alpha value is 1.0.
57-
public let C4Blue = C4Color(red: 0.098, green: 0.271, blue: 1.0, alpha: 1.0)
58-
///A C4Color object whose RGB value is 0.0, 0.0, 0.541 and whose alpha value is 1.0.
59-
public let C4Purple = C4Color(red: 0.0, green: 0.0, blue: 0.541, alpha: 1.0)
60-
///A C4Color object whose RGB value is 0.98, 0.98, 0.98 and whose alpha value is 1.0.
61-
public let C4Grey = C4Color(red: 0.98, green: 0.98, blue: 0.98, alpha: 1.0)
54+
///A Color object whose RGB value is 1.0, 0.0, 0.475 and whose alpha value is 1.0.
55+
public let C4Pink = Color(red: 1.0, green: 0.0, blue: 0.475, alpha: 1.0)
56+
///A Color object whose RGB value is 0.098, 0.271, 1.0 and whose alpha value is 1.0.
57+
public let C4Blue = Color(red: 0.098, green: 0.271, blue: 1.0, alpha: 1.0)
58+
///A Color object whose RGB value is 0.0, 0.0, 0.541 and whose alpha value is 1.0.
59+
public let C4Purple = Color(red: 0.0, green: 0.0, blue: 0.541, alpha: 1.0)
60+
///A Color object whose RGB value is 0.98, 0.98, 0.98 and whose alpha value is 1.0.
61+
public let C4Grey = Color(red: 0.98, green: 0.98, blue: 0.98, alpha: 1.0)
6262

63-
/// This document describes the C4Color object which represents color and sometimes opacity (alpha value). You can use C4Color
64-
/// objects to store color data, and pass them between various C4 objects such as C4Shape, C4Image, etc.
63+
/// This document describes the Color object which represents color and sometimes opacity (alpha value). You can use Color
64+
/// objects to store color data, and pass them between various C4 objects such as Shape, Image, etc.
6565
///
66-
/// C4Color internally wraps a CGColorSpaceRef called colorSpace, as well as a CGColorRef. From these two objects C4Color is able to
67-
/// properly maintain color data and convert it to / from other color objects such as UIColor, CIColor, C4Color, etc.
68-
public class C4Color {
66+
/// Color internally wraps a CGColorSpaceRef called colorSpace, as well as a CGColorRef. From these two objects Color is able to
67+
/// properly maintain color data and convert it to / from other color objects such as UIColor, CIColor, Color, etc.
68+
public class Color {
6969
internal var colorSpace: CGColorSpaceRef
7070
internal var internalColor: CGColorRef
7171

7272
/// Initializes and returns a new color object. Defaults to black with 0 opacity (i.e. clear).
7373
/// ````
74-
/// let c = C4Color()
74+
/// let c = Color()
7575
/// ````
7676
public init() {
7777
colorSpace = CGColorSpaceCreateDeviceRGB()!
7878
internalColor = CGColorCreate(colorSpace, [0, 0, 0, 0])!
7979
}
8080

81-
/// Initializes and returns a new C4Color object based on specified color values.
81+
/// Initializes and returns a new Color object based on specified color values.
8282
/// ````
83-
/// let c = C4Color(red: 1.0, green: 0.0, blue: 0.0, alpha: 1.0)
83+
/// let c = Color(red: 1.0, green: 0.0, blue: 0.0, alpha: 1.0)
8484
/// ````
8585
/// - parameter red: The red value for the new color [0.0 ... 1.0]
8686
/// - parameter green: The green value for the new color [0.0 ... 1.0]
@@ -91,37 +91,37 @@ public class C4Color {
9191
internalColor = CGColorCreate(colorSpace, [CGFloat(red), CGFloat(green), CGFloat(blue), CGFloat(alpha)])!
9292
}
9393

94-
/// Initializes and returns a new C4Color object based on a provided CGColor object.
94+
/// Initializes and returns a new Color object based on a provided CGColor object.
9595
/// ````
96-
/// let c = C4Color(UIColor.redColor().CGColor)
96+
/// let c = Color(UIColor.redColor().CGColor)
9797
/// ````
98-
/// - parameter color: A CGColor object that will be used to create a new C4Color.
98+
/// - parameter color: A CGColor object that will be used to create a new Color.
9999
public init(_ color: CGColorRef) {
100100
colorSpace = CGColorSpaceCreateDeviceRGB()!
101101
internalColor = color
102102
}
103103

104-
/// Initializes and returns a new C4Color object based on a provided UIColor object.
104+
/// Initializes and returns a new Color object based on a provided UIColor object.
105105
/// ````
106-
/// let c = C4Color(UIColor.redColor())
106+
/// let c = Color(UIColor.redColor())
107107
/// ````
108-
/// - parameter color: A UIColor object whose components will be extrated to create a new C4Color.
108+
/// - parameter color: A UIColor object whose components will be extrated to create a new Color.
109109
public convenience init(_ color: UIColor) {
110110
self.init(color.CGColor)
111111
}
112112

113-
/// Initializes and returns a new C4Color object made up of a repeating pattern based on a specified C4Image.
113+
/// Initializes and returns a new Color object made up of a repeating pattern based on a specified Image.
114114
/// ````
115-
/// let p = C4Color("pattern")
115+
/// let p = Color("pattern")
116116
/// ````
117117
/// - parameter pattern: a String, the name of an image to use as a pattern.
118118
public convenience init(_ pattern: String) {
119119
self.init(UIColor(patternImage: UIImage(named: pattern)!))
120120
}
121121

122-
/// Initializes and returns a new C4Color object based on specified color values.
122+
/// Initializes and returns a new Color object based on specified color values.
123123
/// ````
124-
/// let c = C4Color(red: 255, green: 0, blue: 0, alpha: 255)
124+
/// let c = Color(red: 255, green: 0, blue: 0, alpha: 255)
125125
/// ````
126126
/// - parameter red: The red value for the new color [0 ... 255]
127127
/// - parameter green: The green value for the new color [0 ... 255]
@@ -131,10 +131,10 @@ public class C4Color {
131131
self.init(red: Double(red) / 255.0, green: Double(green) / 255.0, blue: Double(blue) / 255.0, alpha: alpha)
132132
}
133133

134-
/// Initializes and returns a new C4Color object based on a specified hex value.
134+
/// Initializes and returns a new Color object based on a specified hex value.
135135
/// Remember to precede with `0x` and include the alpha component at the end (i.e. 7th + 8th characters)
136136
/// ````
137-
/// let c = C4Color(0xFF0000FF)
137+
/// let c = Color(0xFF0000FF)
138138
/// ````
139139
/// - parameter hexValue: A color value expressed in hexadecimal.
140140
public convenience init(_ hexValue: UInt32) {
@@ -170,7 +170,7 @@ public class C4Color {
170170

171171
/// The value of the red component of the current color, [0.0 ... 1.0]
172172
/// ````
173-
/// let c = C4Color()
173+
/// let c = Color()
174174
/// let redVal = c.red
175175
/// ````
176176
/// - returns: Double value in the range [0.0 ... 1.0]
@@ -185,7 +185,7 @@ public class C4Color {
185185

186186
/// The value of the green component of the current color
187187
/// ````
188-
/// let c = C4Color()
188+
/// let c = Color()
189189
/// let greenVal = c.green
190190
/// ````
191191
/// - returns: Double value in the range [0.0 ... 1.0]
@@ -200,7 +200,7 @@ public class C4Color {
200200

201201
/// The value of the blue component of the current color
202202
/// ````
203-
/// let c = C4Color()
203+
/// let c = Color()
204204
/// let blueVal = c.blue
205205
/// ````
206206
/// - returns: Double value in the range [0.0 ... 1.0]
@@ -215,7 +215,7 @@ public class C4Color {
215215

216216
/// The value of the alpha component of the current color.
217217
/// ````
218-
/// let c = C4Color()
218+
/// let c = Color()
219219
/// let alphaVal = c.alpha
220220
/// ````
221221
/// - returns: Double value in the range [0.0 ... 1.0]
@@ -230,7 +230,7 @@ public class C4Color {
230230

231231
/// A CGColor representation of the current color.
232232
/// ````
233-
/// let c = C4Color()
233+
/// let c = Color()
234234
/// let cg = c.CGColor
235235
/// ````
236236
/// - returns: CGColorRef object that matches the color's `internalColor` property
@@ -246,25 +246,25 @@ public class C4Color {
246246
/// ````
247247
/// - parameter alpha: The opacity value of the new UIColor object.
248248
/// - returns: A new color with a modified alpha component.
249-
public func colorWithAlpha(alpha: Double) -> C4Color {
250-
return C4Color(red: red, green: green, blue: blue, alpha: alpha)
249+
public func colorWithAlpha(alpha: Double) -> Color {
250+
return Color(red: red, green: green, blue: blue, alpha: alpha)
251251
}
252252
}
253253

254254
// MARK: - Casting to UIColor and CIColor
255255

256256
public extension UIColor {
257-
/// Initializes a UIColor object from a C4Color object.
257+
/// Initializes a UIColor object from a Color object.
258258
/// - parameter color: The C4 color object.
259-
public convenience init?(_ color: C4Color) {
259+
public convenience init?(_ color: Color) {
260260
self.init(CGColor: color.CGColor)
261261
}
262262
}
263263

264264
public extension CIColor {
265-
/// Initializes a CIColor object from a C4Color object.
265+
/// Initializes a CIColor object from a Color object.
266266
/// - parameter color: The C4 color object.
267-
public convenience init(_ color: C4Color) {
267+
public convenience init(_ color: Color) {
268268
self.init(CGColor: color.CGColor)
269269
}
270270
}

Diff for: C4/Core/C4EventSource.swift renamed to C4/Core/EventSource.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import Foundation
2121

2222
///This protocol defines 3 required methods for objects to post and listen for notifications, as well as cancel.
23-
public protocol C4EventSource {
23+
public protocol EventSource {
2424

2525
/// Posts a new notification originating from the receiver.
2626
///
@@ -45,7 +45,7 @@ public protocol C4EventSource {
4545
}
4646

4747
/// This extension allows any NSObject to post and listen for events in the same way as C4 objects.
48-
extension NSObject : C4EventSource {
48+
extension NSObject : EventSource {
4949
/// Posts a new notification originating from the receiver.
5050
///
5151
/// ````

Diff for: C4/Core/C4Foundation.swift renamed to C4/Core/Foundation.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ public func CGRectMakeFromPoints(points: [CGPoint]) -> CGRect {
6161
///
6262
/// - parameter delay: The amount of time in seconds to wait before executing the block of code.
6363
/// - parameter action: A block of code to perform after the delay.
64-
public func delay(delay: Double, action: ()->()) {
64+
public func wait(seconds: Double, action: ()->()) {
6565
dispatch_after(
6666
dispatch_time(
6767
DISPATCH_TIME_NOW,
68-
Int64(delay * Double(NSEC_PER_SEC))
68+
Int64(seconds * Double(NSEC_PER_SEC))
6969
),
7070
dispatch_get_main_queue(), action)
7171
}

Diff for: C4/Core/C4Math.swift renamed to C4/Core/Math.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ public func clamp<T: Comparable>(val: T, min: T, max: T) -> T {
4545
/// Linear interpolation. For any two values a and b return a linear interpolation with parameter `param`.
4646
///
4747
/// ````
48-
/// lerp(0,100,0.5) = 50
49-
/// lerp(100,200,0.5) = 150
50-
/// lerp(500,1000,0.33) = 665
48+
/// lerp(0, 100, 0.5) = 50
49+
/// lerp(100, 200, 0.5) = 150
50+
/// lerp(500, 1000, 0.33) = 665
5151
/// ````
5252
///
5353
/// - parameter a: first value
5454
/// - parameter b: second value
5555
/// - parameter param: parameter between 0 and 1 for interpolation
5656
///
5757
/// - returns: The interpolated value
58-
public func lerp(a a: Double, b: Double, param: Double) -> Double {
59-
return a + (b - a) * param
58+
public func lerp(a: Double, _ b: Double, at: Double) -> Double {
59+
return a + (b - a) * at
6060
}
6161

6262
/// Linear mapping. Maps a value in the source range [min, max] to a value in the target range [toMin, toMax] using linear interpolation.
@@ -76,7 +76,7 @@ public func lerp(a a: Double, b: Double, param: Double) -> Double {
7676
/// - returns: The mapped value.
7777
public func map(val: Double, min: Double, max: Double, toMin: Double, toMax: Double) -> Double {
7878
let param = (val - min)/(max - min)
79-
return lerp(a: toMin, b: toMax, param: param)
79+
return lerp(toMin, toMax, at: param)
8080
}
8181

8282
/// Return a random integer below `below`

0 commit comments

Comments
 (0)