Skip to content

Commit c3396e2

Browse files
Reworked color setup to make theming a little easier
1 parent 80d7894 commit c3396e2

File tree

5 files changed

+125
-23
lines changed

5 files changed

+125
-23
lines changed

SpriteKitWatchFace WatchKit App/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleShortVersionString</key>
2020
<string>1.0</string>
2121
<key>CFBundleVersion</key>
22-
<string>51</string>
22+
<string>55</string>
2323
<key>UISupportedInterfaceOrientations</key>
2424
<array>
2525
<string>UIInterfaceOrientationPortrait</string>

SpriteKitWatchFace WatchKit Extension/FaceScene.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,30 @@
1010

1111
NS_ASSUME_NONNULL_BEGIN
1212

13+
typedef enum : NSUInteger {
14+
ThemeHermesPink,
15+
ThemeHermesOrange,
16+
ThemeNavy,
17+
ThemeTidepod,
18+
ThemeBretonnia,
19+
ThemeNoir
20+
} Theme;
21+
1322
@interface FaceScene : SKScene <SKSceneDelegate>
1423

24+
@property Theme theme;
25+
26+
@property SKColor *lightColor;
27+
@property SKColor *darkColor;
28+
@property SKColor *handColor;
29+
@property SKColor *inlayColor;
30+
@property SKColor *markColor;
31+
@property SKColor *textColor;
32+
1533
@end
1634

35+
36+
37+
38+
1739
NS_ASSUME_NONNULL_END

SpriteKitWatchFace WatchKit Extension/FaceScene.m

Lines changed: 100 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ - (instancetype)initWithCoder:(NSCoder *)coder
2222
{
2323
self = [super initWithCoder:coder];
2424
if (self) {
25-
[self setupColors];
2625

27-
if (vectorDisplay)
28-
[self setupTickmarks];
26+
self.theme = ThemeHermesPink;
27+
28+
[self setupColors];
29+
[self setupScene];
2930

3031
self.delegate = self;
3132
}
@@ -43,15 +44,13 @@ -(void)setupTickmarks
4344
CGFloat faceWidth = 184;
4445
CGFloat faceHeight = 224;
4546

46-
SKColor *accentColor = [SKColor colorWithRed:0.831 green:0.540 blue:0.612 alpha:1];
47-
4847
for (int i = 0; i < 12; i++)
4948
{
5049
CGFloat angle = -(2*M_PI)/12.0 * i;
5150
CGFloat workingRadius = faceWidth/2;
5251
CGFloat longTickHeight = workingRadius/15;
5352

54-
SKSpriteNode *tick = [SKSpriteNode spriteNodeWithColor:accentColor size:CGSizeMake(2, longTickHeight)];
53+
SKSpriteNode *tick = [SKSpriteNode spriteNodeWithColor:self.markColor size:CGSizeMake(2, longTickHeight)];
5554

5655
tick.position = CGPointZero;
5756
tick.anchorPoint = CGPointMake(0.5, (workingRadius-margin)/longTickHeight);
@@ -61,7 +60,7 @@ -(void)setupTickmarks
6160

6261
CGFloat h = 25;
6362

64-
NSDictionary *attribs = @{NSFontAttributeName : [NSFont systemFontOfSize:h], NSForegroundColorAttributeName : [SKColor whiteColor]};
63+
NSDictionary *attribs = @{NSFontAttributeName : [NSFont systemFontOfSize:h], NSForegroundColorAttributeName : self.textColor};
6564

6665
NSAttributedString *labelText = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%i", i == 0 ? 12 : i] attributes:attribs];
6766

@@ -76,7 +75,7 @@ -(void)setupTickmarks
7675
CGFloat angle = - (2*M_PI)/60.0 * i;
7776
CGFloat workingRadius = faceWidth/2;
7877
CGFloat shortTickHeight = workingRadius/20;
79-
SKSpriteNode *tick = [SKSpriteNode spriteNodeWithColor:accentColor size:CGSizeMake(1, shortTickHeight)];
78+
SKSpriteNode *tick = [SKSpriteNode spriteNodeWithColor:self.markColor size:CGSizeMake(1, shortTickHeight)];
8079

8180
tick.position = CGPointZero;
8281
tick.anchorPoint = CGPointMake(0.5, (workingRadius-margin)/shortTickHeight);
@@ -94,13 +93,91 @@ -(void)setupTickmarks
9493
numbersLayer.alpha = 0;
9594
}
9695

97-
9896
-(void)setupColors
9997
{
100-
SKColor *lightColor = [SKColor colorWithRed:0.848 green:0.187 blue:0.349 alpha:1];
101-
SKColor *darkColor = [SKColor colorWithRed:0.387 green:0.226 blue:0.270 alpha:1];
102-
SKColor *accentColor = [SKColor colorWithRed:0.831 green:0.540 blue:0.612 alpha:1];
98+
SKColor *lightColor = nil;
99+
SKColor *darkColor = nil;
100+
SKColor *markColor = nil;
101+
SKColor *inlayColor = nil;
102+
SKColor *handColor = nil;
103+
SKColor *textColor = nil;
104+
105+
switch (self.theme) {
106+
case ThemeHermesPink:
107+
{
108+
lightColor = [SKColor colorWithRed:0.848 green:0.187 blue:0.349 alpha:1];
109+
darkColor = [SKColor colorWithRed:0.387 green:0.226 blue:0.270 alpha:1];
110+
markColor = [SKColor colorWithRed:0.831 green:0.540 blue:0.612 alpha:1];
111+
inlayColor = lightColor;
112+
handColor = [SKColor whiteColor];
113+
textColor = [SKColor whiteColor];
114+
break;
115+
}
116+
case ThemeHermesOrange:
117+
{
118+
lightColor = [SKColor colorWithRed:0.892 green:0.825 blue:0.745 alpha:1.000];
119+
darkColor = [SKColor colorWithRed:0.118 green:0.188 blue:0.239 alpha:1.000];
120+
inlayColor = [SKColor colorWithRed:1.000 green:0.450 blue:0.136 alpha:1.000];
121+
markColor = [inlayColor colorWithAlphaComponent:0.5];
122+
handColor = [SKColor whiteColor];
123+
textColor = inlayColor;
124+
break;
125+
}
126+
case ThemeNavy:
127+
{
128+
lightColor = [SKColor colorWithRed:0.067 green:0.471 blue:0.651 alpha:1.000];
129+
darkColor = [SKColor colorWithRed:0.118 green:0.188 blue:0.239 alpha:1.000];
130+
inlayColor = lightColor;
131+
markColor = [SKColor whiteColor];
132+
handColor = [SKColor whiteColor];
133+
textColor = [SKColor whiteColor];
134+
break;
135+
}
136+
case ThemeTidepod:
137+
{
138+
lightColor = [SKColor colorWithRed:1.000 green:0.450 blue:0.136 alpha:1.000];
139+
darkColor = [SKColor colorWithRed:0.067 green:0.471 blue:0.651 alpha:1.000];
140+
inlayColor = [SKColor colorWithRed:0.953 green:0.569 blue:0.196 alpha:1.000];
141+
markColor = [SKColor whiteColor];
142+
handColor = [SKColor whiteColor];
143+
textColor = [SKColor whiteColor];
144+
break;
145+
}
146+
case ThemeBretonnia:
147+
{
148+
lightColor = [SKColor colorWithRed:0.067 green:0.420 blue:0.843 alpha:1.000];
149+
darkColor = [SKColor colorWithRed:0.956 green:0.137 blue:0.294 alpha:1.000];
150+
inlayColor = darkColor;
151+
markColor = [SKColor whiteColor];
152+
handColor = [SKColor whiteColor];
153+
textColor = [SKColor whiteColor];
154+
break;
155+
}
156+
case ThemeNoir:
157+
{
158+
lightColor = [SKColor colorWithWhite:0.3 alpha:1.0];
159+
darkColor = [SKColor blackColor];
160+
inlayColor = darkColor;
161+
markColor = [SKColor whiteColor];
162+
handColor = [SKColor whiteColor];
163+
textColor = [SKColor whiteColor];
164+
break;
165+
}
166+
167+
default:
168+
break;
169+
}
103170

171+
self.lightColor = lightColor;
172+
self.darkColor = darkColor;
173+
self.markColor = markColor;
174+
self.inlayColor = inlayColor;
175+
self.textColor = textColor;
176+
self.handColor = handColor;
177+
}
178+
179+
-(void)setupScene
180+
{
104181
SKNode *face = [self childNodeWithName:@"Face"];
105182

106183
SKSpriteNode *hourHand = (SKSpriteNode *)[face childNodeWithName:@"Hours"];
@@ -113,28 +190,31 @@ -(void)setupColors
113190
SKSpriteNode *colorRegion = (SKSpriteNode *)[face childNodeWithName:@"Color Region"];
114191
SKSpriteNode *numbers = (SKSpriteNode *)[face childNodeWithName:@"Numbers"];
115192

116-
hourHand.color = [SKColor whiteColor];
193+
hourHand.color = self.handColor;
117194
hourHand.colorBlendFactor = 1.0;
118195

119-
minuteHand.color = [SKColor whiteColor];
196+
minuteHand.color = self.handColor;
120197
minuteHand.colorBlendFactor = 1.0;
121198

122-
secondHand.color = accentColor;
199+
secondHand.color = self.markColor;
123200
secondHand.colorBlendFactor = 1.0;
124201

125-
self.backgroundColor = darkColor;
202+
self.backgroundColor = self.darkColor;
126203

127-
colorRegion.color = lightColor;
204+
colorRegion.color = self.lightColor;
128205
colorRegion.colorBlendFactor = 1.0;
129206

130-
numbers.color = accentColor;
207+
numbers.color = self.textColor;
131208
numbers.colorBlendFactor = 1.0;
132209

133-
hourHandInlay.color = lightColor;
210+
hourHandInlay.color = self.inlayColor;
134211
hourHandInlay.colorBlendFactor = 1.0;
135212

136-
minuteHandInlay.color = lightColor;
213+
minuteHandInlay.color = self.inlayColor;
137214
minuteHandInlay.colorBlendFactor = 1.0;
215+
216+
if (vectorDisplay)
217+
[self setupTickmarks];
138218
}
139219

140220
- (void)update:(NSTimeInterval)currentTime forScene:(SKScene *)scene

SpriteKitWatchFace WatchKit Extension/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleShortVersionString</key>
2020
<string>1.0</string>
2121
<key>CFBundleVersion</key>
22-
<string>51</string>
22+
<string>55</string>
2323
<key>NSExtension</key>
2424
<dict>
2525
<key>NSExtensionAttributes</key>

SpriteKitWatchFace/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundleShortVersionString</key>
1818
<string>1.0</string>
1919
<key>CFBundleVersion</key>
20-
<string>51</string>
20+
<string>55</string>
2121
<key>LSRequiresIPhoneOS</key>
2222
<true/>
2323
<key>UILaunchStoryboardName</key>

0 commit comments

Comments
 (0)