Skip to content

Commit 39c8feb

Browse files
authored
Merge pull request #17 from dylan/develop
Develop
2 parents 5eccd89 + 262ae32 commit 39c8feb

File tree

12 files changed

+260
-104
lines changed

12 files changed

+260
-104
lines changed

Colors-macOS.playground/Contents.swift

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,29 @@ let color1 = Color(red: 1.0, green: 1.0, blue: 1.0)
77

88
let color2 = Color(redInt: 255, greenInt: 255, blueInt: 255)
99

10+
Color.contrastRatio(of: .white, and: .black)
11+
12+
Color.luminance(of: .white)
13+
1014
let color3 = Color(hex: 0xffffff)
15+
color3.rgb
16+
color3.lab
17+
color3.xyz
18+
color3.hsl
19+
color3.hsv
20+
color3.cmyk
1121

1222
color1 == color2
1323
color2 == color3
1424

15-
var dinerGreen = Color(hex: 0x36ecbd)
16-
17-
dinerGreen.hsl
25+
var dinerGreen = Color(hex: 0x37ecbd)
1826

1927
dinerGreen.rgb
28+
dinerGreen.hsl
29+
dinerGreen.hsv
30+
dinerGreen.cmyk
31+
dinerGreen.xyz
32+
dinerGreen.lab
2033

2134
dinerGreen.hex
2235
dinerGreen.hexString
@@ -29,8 +42,8 @@ dinerGreen.luminance
2942
0xffffff == Color.white.hex
3043

3144
dinerGreen.hueShifted(180).view
32-
dinerGreen.lightened(0.3).view
33-
dinerGreen.darkened(0.3).view
45+
dinerGreen.lightened(0.5).view
46+
dinerGreen.darkened(0.5).view
3447
dinerGreen.saturated(1.0).view
3548
dinerGreen.desaturated(1.0).view
3649

@@ -39,7 +52,7 @@ dinerGreen.hsv.saturation = 0
3952

4053
dinerGreen.view
4154

42-
dinerGreen.mixed(with: .red, percent: 0.5).view
55+
Color.blue.mixed(with: .red, percent: 0.5).view
4356

4457
let ramp = [Color(hex: 0x000000), // Black
4558
Color(hex: 0xff0000), // Red
@@ -48,27 +61,26 @@ let ramp = [Color(hex: 0x000000), // Black
4861
Color(hex: 0x000000), // Black
4962
Color(hex: 0xffffff)] // White
5063

51-
[Color.red, Color.blue].spread(to: 8).view
52-
[Color.red, Color.blue].spread(to: 8, using: .rgb).view
53-
54-
ramp.spread(to: 32, using: .hue).view
64+
ramp.spread(to: 16, using: .hue).view
5565

56-
ramp.spread(to: 32, using: .rgb).view
66+
ramp.spread(to: 16, using: .rgb).view
5767

5868
let sexyRamp = [Color(hex: 0xde6161),
5969
Color(hex: 0x2657eb)]
6070

6171
sexyRamp.spread(to: 16, using: .rgb).view
6272

6373
sexyRamp.spread(to: 16, using: .hue).view
74+
[Color.red, Color.blue].spread(to: 8).view
75+
[Color.red, Color.blue].spread(to: 8, using: .rgb).view
6476

6577
let x11ColorRamp: [Color] = [X11.green, X11.lightBlue, X11.beige, X11.chartreuse, X11.darkOliveGreen, X11.purple]
6678
x11ColorRamp.view
6779

6880
let w3cColorRamp: [Color] = [W3C.green, W3C.lightblue, W3C.beige, W3C.chartreuse, W3C.darkolivegreen, W3C.purple]
6981
w3cColorRamp.view
7082

71-
let namedColorRamp: [Color] = [.black, .white, .brown, .cyan, .green]
83+
let namedColorRamp: [Color] = [.black, .darkGray, .lightGray, .white, .gray, .red, .green, .blue, .cyan, .yellow, .magenta, .orange, .purple, .brown]
7284
namedColorRamp.view
7385

7486
Resene.copperFire.hexString

Colors-macOS.playground/timeline.xctimeline

Lines changed: 60 additions & 50 deletions
Large diffs are not rendered by default.

Colors.xcodeproj/project.pbxproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@
125125
FC6B96171EC0E96800E0B30B /* Color+XKCD.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC6B96121EC0E96800E0B30B /* Color+XKCD.swift */; };
126126
FC6B96181EC0E96800E0B30B /* Color+XKCD.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC6B96121EC0E96800E0B30B /* Color+XKCD.swift */; };
127127
FC6B96191EC0E96800E0B30B /* Color+XKCD.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC6B96121EC0E96800E0B30B /* Color+XKCD.swift */; };
128+
FC6B961B1EC1F18300E0B30B /* FloatingPoint+Units.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC6B961A1EC1F18300E0B30B /* FloatingPoint+Units.swift */; };
129+
FC6B961C1EC1F18300E0B30B /* FloatingPoint+Units.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC6B961A1EC1F18300E0B30B /* FloatingPoint+Units.swift */; };
130+
FC6B961D1EC1F18300E0B30B /* FloatingPoint+Units.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC6B961A1EC1F18300E0B30B /* FloatingPoint+Units.swift */; };
131+
FC6B961E1EC1F18300E0B30B /* FloatingPoint+Units.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC6B961A1EC1F18300E0B30B /* FloatingPoint+Units.swift */; };
132+
FC6B961F1EC1F18300E0B30B /* FloatingPoint+Units.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC6B961A1EC1F18300E0B30B /* FloatingPoint+Units.swift */; };
133+
FC6B96201EC1F18300E0B30B /* FloatingPoint+Units.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC6B961A1EC1F18300E0B30B /* FloatingPoint+Units.swift */; };
134+
FC6B96211EC1F18300E0B30B /* FloatingPoint+Units.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC6B961A1EC1F18300E0B30B /* FloatingPoint+Units.swift */; };
128135
FC81F4C51E9D14A400199604 /* Color+Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC81F4C41E9D14A400199604 /* Color+Operators.swift */; };
129136
FC81F4C61E9D14A400199604 /* Color+Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC81F4C41E9D14A400199604 /* Color+Operators.swift */; };
130137
FC81F4C71E9D14A400199604 /* Color+Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC81F4C41E9D14A400199604 /* Color+Operators.swift */; };
@@ -199,6 +206,7 @@
199206
FC6B95ED1EC0DC1000E0B30B /* Colors+W3C.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Colors+W3C.swift"; sourceTree = "<group>"; };
200207
FC6B95EE1EC0DC1000E0B30B /* Colors+X11.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Colors+X11.swift"; sourceTree = "<group>"; };
201208
FC6B96121EC0E96800E0B30B /* Color+XKCD.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Color+XKCD.swift"; sourceTree = "<group>"; };
209+
FC6B961A1EC1F18300E0B30B /* FloatingPoint+Units.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FloatingPoint+Units.swift"; sourceTree = "<group>"; };
202210
FC81F4C41E9D14A400199604 /* Color+Operators.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Color+Operators.swift"; sourceTree = "<group>"; };
203211
FC81F4D41E9D236600199604 /* Types.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Types.swift; sourceTree = "<group>"; };
204212
FCBB686D1E9D095B000F4E94 /* Math.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Math.swift; sourceTree = "<group>"; };
@@ -326,6 +334,7 @@
326334
FCBB686D1E9D095B000F4E94 /* Math.swift */,
327335
FC81F4D41E9D236600199604 /* Types.swift */,
328336
FC6B95E91EC0DC1000E0B30B /* Named */,
337+
FC6B961A1EC1F18300E0B30B /* FloatingPoint+Units.swift */,
329338
);
330339
path = Sources;
331340
sourceTree = "<group>";
@@ -623,6 +632,7 @@
623632
isa = PBXSourcesBuildPhase;
624633
buildActionMask = 2147483647;
625634
files = (
635+
FC6B961B1EC1F18300E0B30B /* FloatingPoint+Units.swift in Sources */,
626636
FC1D35401E9D3624007D31CE /* Color+Adjustment.swift in Sources */,
627637
FC81F4C51E9D14A400199604 /* Color+Operators.swift in Sources */,
628638
52D6D9981BEFF375002C0205 /* Color.swift in Sources */,
@@ -655,6 +665,7 @@
655665
FC12C2AA1E9502EC00AC1E7F /* Color.swift in Sources */,
656666
FC1D35541E9D36B0007D31CE /* Array+Color.swift in Sources */,
657667
FC6B95D41EC0791600E0B30B /* ColorSpace.swift in Sources */,
668+
FC6B961F1EC1F18300E0B30B /* FloatingPoint+Units.swift in Sources */,
658669
FC1D355C1E9D3701007D31CE /* ColorView.swift in Sources */,
659670
FC6B96081EC0DC1000E0B30B /* Colors+W3C.swift in Sources */,
660671
FC81F4C91E9D14A400199604 /* Color+Operators.swift in Sources */,
@@ -676,6 +687,7 @@
676687
isa = PBXSourcesBuildPhase;
677688
buildActionMask = 2147483647;
678689
files = (
690+
FC6B961D1EC1F18300E0B30B /* FloatingPoint+Units.swift in Sources */,
679691
FC1D35421E9D3624007D31CE /* Color+Adjustment.swift in Sources */,
680692
FC81F4C71E9D14A400199604 /* Color+Operators.swift in Sources */,
681693
52D6D9EA1BEFFFA4002C0205 /* Color.swift in Sources */,
@@ -702,6 +714,7 @@
702714
isa = PBXSourcesBuildPhase;
703715
buildActionMask = 2147483647;
704716
files = (
717+
FC6B961E1EC1F18300E0B30B /* FloatingPoint+Units.swift in Sources */,
705718
FC1D35431E9D3624007D31CE /* Color+Adjustment.swift in Sources */,
706719
FC81F4C81E9D14A400199604 /* Color+Operators.swift in Sources */,
707720
52D6DA091BF00081002C0205 /* Color.swift in Sources */,
@@ -728,6 +741,7 @@
728741
isa = PBXSourcesBuildPhase;
729742
buildActionMask = 2147483647;
730743
files = (
744+
FC6B961C1EC1F18300E0B30B /* FloatingPoint+Units.swift in Sources */,
731745
FC1D35411E9D3624007D31CE /* Color+Adjustment.swift in Sources */,
732746
FC81F4C61E9D14A400199604 /* Color+Operators.swift in Sources */,
733747
52D6DA261BF00118002C0205 /* Color.swift in Sources */,
@@ -760,6 +774,7 @@
760774
DD7502861C68FDDC006590AF /* ColorsTests.swift in Sources */,
761775
FC1D35551E9D36B0007D31CE /* Array+Color.swift in Sources */,
762776
FC6B95D51EC0791600E0B30B /* ColorSpace.swift in Sources */,
777+
FC6B96201EC1F18300E0B30B /* FloatingPoint+Units.swift in Sources */,
763778
FC1D355D1E9D3701007D31CE /* ColorView.swift in Sources */,
764779
FC6B96091EC0DC1000E0B30B /* Colors+W3C.swift in Sources */,
765780
FC81F4CA1E9D14A400199604 /* Color+Operators.swift in Sources */,
@@ -787,6 +802,7 @@
787802
FC12C2AC1E9502EE00AC1E7F /* Color.swift in Sources */,
788803
FC1D35561E9D36B0007D31CE /* Array+Color.swift in Sources */,
789804
FC6B95D61EC0791600E0B30B /* ColorSpace.swift in Sources */,
805+
FC6B96211EC1F18300E0B30B /* FloatingPoint+Units.swift in Sources */,
790806
FC1D355E1E9D3701007D31CE /* ColorView.swift in Sources */,
791807
FC6B960A1EC0DC1000E0B30B /* Colors+W3C.swift in Sources */,
792808
FC81F4CB1E9D14A400199604 /* Color+Operators.swift in Sources */,

Configs/Frameworks/Colors.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>0.9.6</string>
18+
<string>0.9.7</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

Sources/Color+Adjustment.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ extension Color {
2020
}
2121

2222
var result = color
23-
result.hsl.hue += degrees / 360
23+
result.hsl.hue = (result.hsl.hue + degrees).degrees
2424
return result
2525
}
2626

@@ -36,7 +36,7 @@ extension Color {
3636
}
3737

3838
var result = color
39-
result.hsl.luminosity -= percent
39+
result.hsl.luminosity -= (result.hsl.luminosity * percent).percent
4040
return result
4141
}
4242

@@ -52,7 +52,7 @@ extension Color {
5252
}
5353

5454
var result = color
55-
result.hsl.luminosity += percent
55+
result.hsl.luminosity += (result.hsl.luminosity * percent).percent
5656
return result
5757
}
5858

@@ -68,7 +68,7 @@ extension Color {
6868
}
6969

7070
var result = color
71-
result.hsl.saturation += percent
71+
result.hsl.saturation += (result.hsl.saturation * percent).percent
7272
return result
7373
}
7474

@@ -84,7 +84,7 @@ extension Color {
8484
}
8585

8686
var result = color
87-
result.hsl.saturation -= percent
87+
result.hsl.saturation -= (result.hsl.saturation * percent).percent
8888
return result
8989
}
9090

@@ -110,7 +110,7 @@ extension Color {
110110
return Color(red: mix(a: a.rgb.red, b: b.rgb.red, percent: percent),
111111
green: mix(a: a.rgb.green, b: b.rgb.green, percent: percent),
112112
blue: mix(a: a.rgb.blue, b: b.rgb.blue, percent: percent),
113-
alpha: mix(a: a.alpha, b: b.alpha, percent: percent))
113+
alpha: mix(a: a.alpha, b: b.alpha, percent: percent))
114114

115115
}
116116

0 commit comments

Comments
 (0)