Oolite
Loading...
Searching...
No Matches
SkyEntity(OOPrivate) Category Reference

Instance Methods

(BOOL) - readColor1:andColor2:andColor3:andColor4:fromDictionary:

Detailed Description

Definition at line 43 of file SkyEntity.m.

Method Documentation

◆ readColor1:andColor2:andColor3:andColor4:fromDictionary:

- (BOOL) readColor1: (OOColor**) ioColor1
andColor2: (OOColor**) ioColor2
andColor3: (OOColor**) ioColor3
andColor4: (OOColor**) ioColor4
fromDictionary: (NSDictionary*) dictionary 

Extends class SkyEntity.

Definition at line 229 of file SkyEntity.m.

229 :(OOColor**)ioColor1 andColor2:(OOColor**)ioColor2 andColor3:(OOColor**)ioColor3 andColor4:(OOColor**)ioColor4 fromDictionary:(NSDictionary*)dictionary
230{
231 NSString* string = nil;
232 NSArray* tokens = nil;
233 id colorDesc = nil;
234 OOColor* color = nil;
235 BOOL nebulaSet = NO;
236
237 assert(ioColor1 != NULL && ioColor2 != NULL);
238
239 string = [dictionary oo_stringForKey:@"sky_rgb_colors"];
240 if (string != nil) {
241 tokens = ScanTokensFromString(string);
242
243 if ([tokens count] == 6) {
244 float r1 = OOClamp_0_1_f([tokens oo_floatAtIndex:0]);
245 float g1 = OOClamp_0_1_f([tokens oo_floatAtIndex:1]);
246 float b1 = OOClamp_0_1_f([tokens oo_floatAtIndex:2]);
247 float r2 = OOClamp_0_1_f([tokens oo_floatAtIndex:3]);
248 float g2 = OOClamp_0_1_f([tokens oo_floatAtIndex:4]);
249 float b2 = OOClamp_0_1_f([tokens oo_floatAtIndex:5]);
250 *ioColor1 = [OOColor colorWithRed:r1 green:g1 blue:b1 alpha:1.0];
251 *ioColor2 = [OOColor colorWithRed:r2 green:g2 blue:b2 alpha:1.0];
252 } else {
253 OOLogWARN(@"sky.fromDict", @"could not interpret \"%@\" as two RGB colours (must be six numbers).", string);
254 }
255 }
256 colorDesc = [dictionary objectForKey:@"sky_color_1"];
257 if (colorDesc != nil) {
258 color = [[OOColor colorWithDescription:colorDesc] premultipliedColor];
259 if (color != nil)
260 *ioColor1 = color;
261 else
262 OOLogWARN(@"sky.fromDict", @"could not interpret \"%@\" as a colour.", colorDesc);
263 }
264 colorDesc = [dictionary objectForKey:@"sky_color_2"];
265 if (colorDesc != nil) {
266 color = [[OOColor colorWithDescription:colorDesc] premultipliedColor];
267 if (color != nil)
268 *ioColor2 = color;
269 else
270 OOLogWARN(@"sky.fromDict", @"could not interpret \"%@\" as a colour.", colorDesc);
271 }
272
273 colorDesc = [dictionary objectForKey:@"nebula_color_1"];
274 if (colorDesc != nil) {
275 color = [[OOColor colorWithDescription:colorDesc] premultipliedColor];
276 if (color != nil) {
277 *ioColor3 = color;
278 nebulaSet = YES;
279 } else
280 OOLogWARN(@"sky.fromDict", @"could not interpret \"%@\" as a colour.", colorDesc);
281 } else {
282 colorDesc = [dictionary objectForKey:@"sky_color_1"];
283 if (colorDesc != nil) {
284 color = [[OOColor colorWithDescription:colorDesc] premultipliedColor];
285 if (color != nil)
286 *ioColor3 = color;
287 else
288 OOLogWARN(@"sky.fromDict", @"could not interpret \"%@\" as a colour.", colorDesc);
289 }
290 }
291
292 colorDesc = [dictionary objectForKey:@"nebula_color_2"];
293 if (colorDesc != nil) {
294 color = [[OOColor colorWithDescription:colorDesc] premultipliedColor];
295 if (color != nil) {
296 *ioColor4 = color;
297 nebulaSet = YES;
298 } else
299 OOLogWARN(@"sky.fromDict", @"could not interpret \"%@\" as a colour.", colorDesc);
300 } else {
301 colorDesc = [dictionary objectForKey:@"sky_color_2"];
302 if (colorDesc != nil) {
303 color = [[OOColor colorWithDescription:colorDesc] premultipliedColor];
304 if (color != nil)
305 *ioColor4 = color;
306 else
307 OOLogWARN(@"sky.fromDict", @"could not interpret \"%@\" as a colour.", colorDesc);
308 }
309 }
310 return nebulaSet;
311}
OOINLINE float OOClamp_0_1_f(float value) INLINE_CONST_FUNC
#define OOLogWARN(class, format,...)
Definition OOLogging.h:126
unsigned count
return nil
NSMutableArray * ScanTokensFromString(NSString *values)
OOColor * colorWithRed:green:blue:alpha:(float red,[green] float green,[blue] float blue,[alpha] float alpha)
Definition OOColor.m:107
OOColor * colorWithDescription:(id description)
Definition OOColor.m:135
OOColor * premultipliedColor()
Definition OOColor.m:447

References OOColor::colorWithDescription:, OOColor::colorWithRed:green:blue:alpha:, count, nil, OOClamp_0_1_f(), OOLogWARN, OOColor::premultipliedColor, and ScanTokensFromString().

Here is the call graph for this function:

The documentation for this category was generated from the following file: