Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
SkyEntity(OOPrivate) Category Reference

Instance Methods

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

Detailed Description

Definition at line 46 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 1 of file SkyEntity.m.

258 :(OOColor **)ioColor1 andColor2:(OOColor **)ioColor2 andColor3:(OOColor **)ioColor3 andColor4:(OOColor **)ioColor4 fromDictionary:(NSDictionary *)dictionary
259{
260 NSString *string = nil;
261 NSArray *tokens = nil;
262 id colorDesc = nil;
263 OOColor *color = nil;
264 BOOL nebulaSet = NO;
265
266 assert(ioColor1 != NULL && ioColor2 != NULL);
267
268 string = [dictionary oo_stringForKey:@"sky_rgb_colors"];
269 if (string != nil)
270 {
271 tokens = ScanTokensFromString(string);
272
273 if ([tokens count] == 6)
274 {
275 float r1 = OOClamp_0_1_f([tokens oo_floatAtIndex:0]);
276 float g1 = OOClamp_0_1_f([tokens oo_floatAtIndex:1]);
277 float b1 = OOClamp_0_1_f([tokens oo_floatAtIndex:2]);
278 float r2 = OOClamp_0_1_f([tokens oo_floatAtIndex:3]);
279 float g2 = OOClamp_0_1_f([tokens oo_floatAtIndex:4]);
280 float b2 = OOClamp_0_1_f([tokens oo_floatAtIndex:5]);
281 *ioColor1 = [OOColor colorWithRed:r1 green:g1 blue:b1 alpha:1.0];
282 *ioColor2 = [OOColor colorWithRed:r2 green:g2 blue:b2 alpha:1.0];
283 }
284 else
285 {
286 OOLogWARN(@"sky.fromDict", @"could not interpret \"%@\" as two RGB colours (must be six numbers).", string);
287 }
288 }
289 colorDesc = [dictionary objectForKey:@"sky_color_1"];
290 if (colorDesc != nil)
291 {
292 color = [[OOColor colorWithDescription:colorDesc] premultipliedColor];
293 if (color != nil) *ioColor1 = color;
294 else OOLogWARN(@"sky.fromDict", @"could not interpret \"%@\" as a colour.", colorDesc);
295 }
296 colorDesc = [dictionary objectForKey:@"sky_color_2"];
297 if (colorDesc != nil)
298 {
299 color = [[OOColor colorWithDescription:colorDesc] premultipliedColor];
300 if (color != nil) *ioColor2 = color;
301 else OOLogWARN(@"sky.fromDict", @"could not interpret \"%@\" as a colour.", colorDesc);
302 }
303
304 colorDesc = [dictionary objectForKey:@"nebula_color_1"];
305 if (colorDesc != nil)
306 {
307 color = [[OOColor colorWithDescription:colorDesc] premultipliedColor];
308 if (color != nil)
309 {
310 *ioColor3 = color;
311 nebulaSet = YES;
312 }
313 else OOLogWARN(@"sky.fromDict", @"could not interpret \"%@\" as a colour.", colorDesc);
314 }
315 else
316 {
317 colorDesc = [dictionary objectForKey:@"sky_color_1"];
318 if (colorDesc != nil)
319 {
320 color = [[OOColor colorWithDescription:colorDesc] premultipliedColor];
321 if (color != nil) *ioColor3 = color;
322 else OOLogWARN(@"sky.fromDict", @"could not interpret \"%@\" as a colour.", colorDesc);
323 }
324 }
325
326 colorDesc = [dictionary objectForKey:@"nebula_color_2"];
327 if (colorDesc != nil)
328 {
329 color = [[OOColor colorWithDescription:colorDesc] premultipliedColor];
330 if (color != nil)
331 {
332 *ioColor4 = color;
333 nebulaSet = YES;
334 }
335 else OOLogWARN(@"sky.fromDict", @"could not interpret \"%@\" as a colour.", colorDesc);
336 }
337 else
338 {
339 colorDesc = [dictionary objectForKey:@"sky_color_2"];
340 if (colorDesc != nil)
341 {
342 color = [[OOColor colorWithDescription:colorDesc] premultipliedColor];
343 if (color != nil) *ioColor4 = color;
344 else OOLogWARN(@"sky.fromDict", @"could not interpret \"%@\" as a colour.", colorDesc);
345 }
346 }
347 return nebulaSet;
348}
#define OOLogWARN(class, format,...)
Definition OOLogging.h:113
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:95
OOColor * colorWithDescription:(id description)
Definition OOColor.m:127
OOColor * premultipliedColor()
Definition OOColor.m:492

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