Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
OOColor Class Reference

#include <OOColor.h>

+ Inheritance diagram for OOColor:
+ Collaboration diagram for OOColor:

Instance Methods

(OOColor *) - blendedColorWithFraction:ofColor:
 
(float) - redComponent
 
(float) - greenComponent
 
(float) - blueComponent
 
(void) - getRed:green:blue:alpha:
 
(OORGBAComponents- rgbaComponents
 
(BOOL) - isBlack
 
(BOOL) - isWhite
 
(float) - hueComponent
 
(float) - saturationComponent
 
(float) - brightnessComponent
 
(void) - getHue:saturation:brightness:alpha:
 
(OOHSBAComponents- hsbaComponents
 
(float) - alphaComponent
 
(OOColor *) - premultipliedColor
 
(OOColor *) - colorWithBrightnessFactor:
 
(NSArray *) - normalizedArray
 
(NSString *) - rgbaDescription
 
(NSString *) - hsbaDescription
 
(void) - setRed:green:blue:alpha: [implementation]
 
(void) - setHue:saturation:brightness:alpha: [implementation]
 
(id) - copyWithZone: [implementation]
 
(NSString *) - descriptionComponents [implementation]
 
(NSColor *) - asNSColor
 

Class Methods

(OOColor *) + colorWithHue:saturation:brightness:alpha:
 
(OOColor *) + colorWithRed:green:blue:alpha:
 
(OOColor *) + colorWithWhite:alpha:
 
(OOColor *) + colorWithRGBAComponents:
 
(OOColor *) + colorWithHSBAComponents:
 
(OOColor *) + colorWithDescription:
 
(OOColor *) + brightColorWithDescription:
 
(OOColor *) + colorWithDescription:saturationFactor:
 
(OOColor *) + colorFromString:
 
(OOColor *) + blackColor
 
(OOColor *) + darkGrayColor
 
(OOColor *) + lightGrayColor
 
(OOColor *) + whiteColor
 
(OOColor *) + grayColor
 
(OOColor *) + redColor
 
(OOColor *) + greenColor
 
(OOColor *) + blueColor
 
(OOColor *) + cyanColor
 
(OOColor *) + yellowColor
 
(OOColor *) + magentaColor
 
(OOColor *) + orangeColor
 
(OOColor *) + purpleColor
 
(OOColor *) + brownColor
 
(OOColor *) + clearColor
 

Private Attributes

float rgba [4]
 

Detailed Description

Definition at line 44 of file OOColor.h.

Method Documentation

◆ alphaComponent

- (float) alphaComponent

Definition at line 544 of file OOColor.m.

487{
488 return rgba[3];
489}
float rgba[4]
Definition OOColor.h:48

Referenced by AddMacroColorIfAppropriate(), fillSquareImageDataWithCloudTexture(), and HeadUpDisplay::hudDrawReticleOnTarget.

+ Here is the caller graph for this function:

◆ asNSColor

- (NSColor *) asNSColor

Provided by category OOColor(NSColorConversion).

Definition at line 1 of file OODebugUtilities.m.

36{
37 float r, g, b, a;
38 [self getRed:&r green:&g blue:&b alpha:&a];
39 return [NSColor colorWithDeviceRed:r green:g blue:b alpha:a];
40}

◆ blackColor

+ (OOColor *) blackColor

Definition at line 544 of file OOColor.m.

239{
240 return [OOColor colorWithWhite:0.0f alpha:1.0f];
241}
OOColor * colorWithWhite:alpha:(float white,[alpha] float alpha)
Definition OOColor.m:103

◆ blendedColorWithFraction:ofColor:

- (OOColor *) blendedColorWithFraction: (float) fraction
ofColor: (OOColor *) color 

Definition at line 544 of file OOColor.m.

328 :(float)fraction ofColor:(OOColor *)color
329{
330 float rgba1[4];
331 [color getRed:&rgba1[0] green:&rgba1[1] blue:&rgba1[2] alpha:&rgba1[3]];
332
333 OOColor *result = [[OOColor alloc] init];
334 [result setRed:OOLerp(rgba[0], rgba1[0], fraction)
335 green:OOLerp(rgba[1], rgba1[1], fraction)
336 blue:OOLerp(rgba[2], rgba1[2], fraction)
337 alpha:OOLerp(rgba[3], rgba1[3], fraction)];
338
339 return [result autorelease];
340}
void getRed:green:blue:alpha:(float *red,[green] float *green,[blue] float *blue,[alpha] float *alpha)
Definition OOColor.m:368
void setRed:green:blue:alpha:(float r, [green] float g, [blue] float b, [alpha] float a)
Definition OOColor.m:33

Referenced by SaturatedColorInRange().

+ Here is the caller graph for this function:

◆ blueColor

+ (OOColor *) blueColor

Definition at line 544 of file OOColor.m.

281{
282 return [OOColor colorWithRed:0.0f green:0.0f blue:1.0f alpha:1.0f];
283}
OOColor * colorWithRed:green:blue:alpha:(float red,[green] float green,[blue] float blue,[alpha] float alpha)
Definition OOColor.m:95

◆ blueComponent

- (float) blueComponent

Definition at line 544 of file OOColor.m.

363{
364 return rgba[2];
365}

Referenced by AddMacroColorIfAppropriate(), fillSquareImageDataWithCloudTexture(), FloatRGBFromDictColor(), and HeadUpDisplay::hudDrawReticleOnTarget.

+ Here is the caller graph for this function:

◆ brightColorWithDescription:

+ (OOColor *) brightColorWithDescription: (id) description

Definition at line 544 of file OOColor.m.

205 :(id)description
206{
207 OOColor *color = [OOColor colorWithDescription:description];
208 if (color == nil || 0.5f <= [color brightnessComponent]) return color;
209
210 return [OOColor colorWithHue:[color hueComponent] / 360.0f saturation:[color saturationComponent] brightness:0.5f alpha:1.0f];
211}
return nil
float saturationComponent()
Definition OOColor.m:425
OOColor * colorWithDescription:(id description)
Definition OOColor.m:127
float hueComponent()
Definition OOColor.m:399
OOColor * colorWithHue:saturation:brightness:alpha:(float hue,[saturation] float saturation,[brightness] float brightness,[alpha] float alpha)
Definition OOColor.m:87
float brightnessComponent()
Definition OOColor.m:432

◆ brightnessComponent

- (float) brightnessComponent

Definition at line 544 of file OOColor.m.

433{
434 float maxrgb = (rgba[0] > rgba[1])? ((rgba[0] > rgba[2])? rgba[0]:rgba[2]):((rgba[1] > rgba[2])? rgba[1]:rgba[2]);
435 return maxrgb;
436}

◆ brownColor

+ (OOColor *) brownColor

Definition at line 544 of file OOColor.m.

317{
318 return [OOColor colorWithRed:0.6f green:0.4f blue:0.2f alpha:1.0f];
319}

◆ clearColor

+ (OOColor *) clearColor

Definition at line 544 of file OOColor.m.

323{
324 return [OOColor colorWithWhite:0.0f alpha:0.0f];
325}

◆ colorFromString:

+ (OOColor *) colorFromString: (NSString*) colorFloatString

Definition at line 544 of file OOColor.m.

214 :(NSString*) colorFloatString
215{
216 float rgbaValue[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
217 NSScanner *scanner = [NSScanner scannerWithString:colorFloatString];
218 float factor = 1.0f;
219 int i;
220
221 for (i = 0; i != 4; ++i)
222 {
223 if (![scanner scanFloat:&rgbaValue[i]])
224 {
225 // Less than three floats or non-float, can't parse -> quit
226 if (i < 3) return nil;
227
228 // If we get here, we only got three components. Make sure alpha is at correct scale:
229 rgbaValue[3] /= factor;
230 }
231 if (1.0f < rgbaValue[i]) factor = 1.0f / 255.0f;
232 }
233
234 return [OOColor colorWithRed:rgbaValue[0] * factor green:rgbaValue[1] * factor blue:rgbaValue[2] * factor alpha:rgbaValue[3] * factor];
235}

◆ colorWithBrightnessFactor:

- (OOColor *) colorWithBrightnessFactor: (float) factor

Definition at line 544 of file OOColor.m.

502 :(float)factor
503{
504 return [OOColor colorWithRed:OOClamp_0_1_f(rgba[0] * factor)
505 green:OOClamp_0_1_f(rgba[1] * factor)
506 blue:OOClamp_0_1_f(rgba[2] * factor)
507 alpha:rgba[3]];
508}

◆ colorWithDescription:

+ (OOColor *) colorWithDescription: (id) description

Definition at line 544 of file OOColor.m.

127 :(id)description
128{
129 return [self colorWithDescription:description saturationFactor:1.0f];
130}

Referenced by CanonicalizeMaterialSpecifier(), EquipmentInfoSetProperty(), FlasherSetProperty(), FloatRGBFromDictColor(), OOPlanetEntity(OOJavaScriptExtensions)::getJSClass:andPrototype:, GetRGBAArrayFromInfo(), GlobalSetGuiColorSettingForKey(), PlayerShipSetProperty(), SetGLColourFromInfo(), ShipSetProperty(), and VisualEffectSetProperty().

+ Here is the caller graph for this function:

◆ colorWithDescription:saturationFactor:

+ (OOColor *) colorWithDescription: (id) description
saturationFactor: (float) factor 

Definition at line 544 of file OOColor.m.

133 :(id)description saturationFactor:(float)factor
134{
135 NSDictionary *dict = nil;
136 OOColor *result = nil;
137
138 if (description == nil) return nil;
139
140 if ([description isKindOfClass:[OOColor class]])
141 {
142 result = [[description copy] autorelease];
143 }
144 else if ([description isKindOfClass:[NSString class]])
145 {
146 if ([description hasSuffix:@"Color"])
147 {
148 // +fooColor selector
149 SEL selector = NSSelectorFromString(description);
150 if ([self respondsToSelector:selector]) result = [self performSelector:selector];
151 }
152 else
153 {
154 // Some other string
155 result = [self colorFromString:description];
156 }
157 }
158 else if ([description isKindOfClass:[NSArray class]])
159 {
160 result = [self colorFromString:[description componentsJoinedByString:@" "]];
161 }
162 else if ([description isKindOfClass:[NSDictionary class]])
163 {
164 dict = description; // Workaround for gnu-gcc's more agressive "multiple methods named..." warnings.
165
166 if ([dict objectForKey:@"hue"] != nil)
167 {
168 // Treat as HSB(A) dictionary
169 float h = [dict oo_floatForKey:@"hue"];
170 float s = [dict oo_floatForKey:@"saturation" defaultValue:1.0f];
171 float b = [dict oo_floatForKey:@"brightness" defaultValue:-1.0f];
172 if (b < 0.0f) b = [dict oo_floatForKey:@"value" defaultValue:1.0f];
173 float a = [dict oo_floatForKey:@"alpha" defaultValue:-1.0f];
174 if (a < 0.0f) a = [dict oo_floatForKey:@"opacity" defaultValue:1.0f];
175
176 // Not "result =", because we handle the saturation scaling here to allow oversaturation.
177 return [OOColor colorWithHue:h / 360.0f saturation:s * factor brightness:b alpha:a];
178 }
179 else
180 {
181 // Treat as RGB(A) dictionary
182 float r = [dict oo_floatForKey:@"red"];
183 float g = [dict oo_floatForKey:@"green"];
184 float b = [dict oo_floatForKey:@"blue"];
185 float a = [dict oo_floatForKey:@"alpha" defaultValue:-1.0f];
186 if (a < 0.0f) a = [dict oo_floatForKey:@"opacity" defaultValue:1.0f];
187
188 result = [OOColor colorWithRed:r green:g blue:b alpha:a];
189 }
190 }
191
192 if (factor != 1.0f && result != nil)
193 {
194 float h, s, b, a;
195 [result getHue:&h saturation:&s brightness:&b alpha:&a];
196 h *= 1.0 / 360.0f; // See note in header.
197 s *= factor;
198 result = [self colorWithHue:h saturation:s brightness:b alpha:a];
199 }
200
201 return result;
202}
void getHue:saturation:brightness:alpha:(float *hue,[saturation] float *saturation,[brightness] float *brightness,[alpha] float *alpha)
Definition OOColor.m:438

◆ colorWithHSBAComponents:

+ (OOColor *) colorWithHSBAComponents: (OOHSBAComponents) components

Definition at line 544 of file OOColor.m.

118 :(OOHSBAComponents)components
119{
120 return [self colorWithHue:components.h / 360.0f
121 saturation:components.s
122 brightness:components.b
123 alpha:components.a];
124}

◆ colorWithHue:saturation:brightness:alpha:

+ (OOColor *) colorWithHue: (float) hue
saturation: (float) saturation
brightness: (float) brightness
alpha: (float) alpha 

Definition at line 544 of file OOColor.m.

87 :(float)hue saturation:(float)saturation brightness:(float)brightness alpha:(float)alpha
88{
89 OOColor* result = [[OOColor alloc] init];
90 [result setHue:360.0f * hue saturation:saturation brightness:brightness alpha:alpha];
91 return [result autorelease];
92}
void setHue:saturation:brightness:alpha:(float h, [saturation] float s, [brightness] float b, [alpha] float a)
Definition OOColor.m:42

Referenced by SaturatedColorInRange().

+ Here is the caller graph for this function:

◆ colorWithRed:green:blue:alpha:

+ (OOColor *) colorWithRed: (float) red
green: (float) green
blue: (float) blue
alpha: (float) alpha 

Definition at line 544 of file OOColor.m.

95 :(float)red green:(float)green blue:(float)blue alpha:(float)alpha
96{
97 OOColor* result = [[OOColor alloc] init];
98 [result setRed:red green:green blue:blue alpha:alpha];
99 return [result autorelease];
100}

Referenced by HeadUpDisplay::OODrawPlanetInfo.

+ Here is the caller graph for this function:

◆ colorWithRGBAComponents:

+ (OOColor *) colorWithRGBAComponents: (OORGBAComponents) components

Definition at line 544 of file OOColor.m.

109 :(OORGBAComponents)components
110{
111 return [self colorWithRed:components.r
112 green:components.g
113 blue:components.b
114 alpha:components.a];
115}

Referenced by ModulateColor().

+ Here is the caller graph for this function:

◆ colorWithWhite:alpha:

+ (OOColor *) colorWithWhite: (float) white
alpha: (float) alpha 

Definition at line 544 of file OOColor.m.

103 :(float)white alpha:(float)alpha
104{
105 return [OOColor colorWithRed:white green:white blue:white alpha:alpha];
106}

◆ copyWithZone:

- (id) copyWithZone: (NSZone *) zone
implementation

Definition at line 544 of file OOColor.m.

80 :(NSZone *)zone
81{
82 // Copy is implemented as retain since OOColor is immutable.
83 return [self retain];
84}

◆ cyanColor

+ (OOColor *) cyanColor

Definition at line 544 of file OOColor.m.

287{
288 return [OOColor colorWithRed:0.0f green:1.0f blue:1.0f alpha:1.0f];
289}

◆ darkGrayColor

+ (OOColor *) darkGrayColor

Definition at line 544 of file OOColor.m.

245{
246 return [OOColor colorWithWhite:1.0f/3.0f alpha:1.0f];
247}

◆ descriptionComponents

- (NSString *) descriptionComponents
implementation

Definition at line 544 of file OOColor.m.

344{
345 return [NSString stringWithFormat:@"%g, %g, %g, %g", rgba[0], rgba[1], rgba[2], rgba[3]];
346}

◆ getHue:saturation:brightness:alpha:

- (void) getHue: (float *) hue
saturation: (float *) saturation
brightness: (float *) brightness
alpha: (float *) alpha 

Definition at line 544 of file OOColor.m.

438 :(float *)hue saturation:(float *)saturation brightness:(float *)brightness alpha:(float *)alpha
439{
440 NSParameterAssert(hue != NULL && saturation != NULL && brightness != NULL && alpha != NULL);
441
442 *alpha = rgba[3];
443
444 float fRed = rgba[0], fGreen = rgba[1], fBlue = rgba[2];
445 float maxrgb = fmax(fRed, fmax(fGreen, fBlue));
446 float minrgb = fmin(fRed, fmin(fGreen, fBlue));
447 float delta = maxrgb - minrgb + 0.0001f;
448 float h = 0.0f;
449 if (maxrgb == fRed && fGreen >= fBlue)
450 {
451 h = 60.0f * (fGreen - fBlue) / delta;
452 }
453 else if (maxrgb == fRed && fGreen < fBlue)
454 {
455 h = 60.0f * (fGreen - fBlue) / delta + 360.0f;
456 }
457 else if (maxrgb == fGreen)
458 {
459 h = 60.0f * (fBlue - fRed) / delta + 120.0f;
460 }
461 else if (maxrgb == fBlue)
462 {
463 h = 60.0f * (fRed - fGreen) / delta + 240.0f;
464 }
465
466 float s = (maxrgb == 0.0f) ? 0.0f : (1.0f - (minrgb / maxrgb));
467
468 *hue = h;
469 *saturation = s;
470 *brightness = maxrgb;
471}

Referenced by SaturatedColorInRange().

+ Here is the caller graph for this function:

◆ getRed:green:blue:alpha:

- (void) getRed: (float *) red
green: (float *) green
blue: (float *) blue
alpha: (float *) alpha 

Definition at line 544 of file OOColor.m.

368 :(float *)red green:(float *)green blue:(float *)blue alpha:(float *)alpha
369{
370 NSParameterAssert(red != NULL && green != NULL && blue != NULL && alpha != NULL);
371
372 *red = rgba[0];
373 *green = rgba[1];
374 *blue = rgba[2];
375 *alpha = rgba[3];
376}

Referenced by ApplyColor(), GetRGBAArrayFromInfo(), and SetGLColourFromInfo().

+ Here is the caller graph for this function:

◆ grayColor

+ (OOColor *) grayColor

Definition at line 544 of file OOColor.m.

263{
264 return [OOColor colorWithWhite:0.5f alpha:1.0f];
265}

◆ greenColor

+ (OOColor *) greenColor

Definition at line 544 of file OOColor.m.

275{
276 return [OOColor colorWithRed:0.0f green:1.0f blue:0.0f alpha:1.0f];
277}

Referenced by HeadUpDisplay::hudDrawReticleOnTarget.

+ Here is the caller graph for this function:

◆ greenComponent

- (float) greenComponent

Definition at line 544 of file OOColor.m.

357{
358 return rgba[1];
359}

Referenced by AddMacroColorIfAppropriate(), fillSquareImageDataWithCloudTexture(), FloatRGBFromDictColor(), and HeadUpDisplay::hudDrawReticleOnTarget.

+ Here is the caller graph for this function:

◆ hsbaComponents

- (OOHSBAComponents) hsbaComponents

Definition at line 544 of file OOColor.m.

475{
477 [self getHue:&c.h
478 saturation:&c.s
479 brightness:&c.b
480 alpha:&c.a];
481 return c;
482}

◆ hsbaDescription

- (NSString *) hsbaDescription

Definition at line 544 of file OOColor.m.

531{
533}
NSString * OOHSBAComponentsDescription(OOHSBAComponents components)
Definition OOColor.m:544
OOHSBAComponents hsbaComponents()
Definition OOColor.m:474

◆ hueComponent

- (float) hueComponent

Definition at line 544 of file OOColor.m.

400{
401 float maxrgb = (rgba[0] > rgba[1])? ((rgba[0] > rgba[2])? rgba[0]:rgba[2]):((rgba[1] > rgba[2])? rgba[1]:rgba[2]);
402 float minrgb = (rgba[0] < rgba[1])? ((rgba[0] < rgba[2])? rgba[0]:rgba[2]):((rgba[1] < rgba[2])? rgba[1]:rgba[2]);
403 float delta = maxrgb - minrgb + 0.0001f;
404 float fRed = rgba[0], fGreen = rgba[1], fBlue = rgba[2];
405 float hue = 0.0f;
406 if (maxrgb == fRed && fGreen >= fBlue)
407 {
408 hue = 60.0f * (fGreen - fBlue) / delta;
409 }
410 else if (maxrgb == fRed && fGreen < fBlue)
411 {
412 hue = 60.0f * (fGreen - fBlue) / delta + 360.0f;
413 }
414 else if (maxrgb == fGreen)
415 {
416 hue = 60.0f * (fBlue - fRed) / delta + 120.0f;
417 }
418 else if (maxrgb == fBlue)
419 {
420 hue = 60.0f * (fRed - fGreen) / delta + 240.0f;
421 }
422 return hue;
423}

◆ isBlack

- (BOOL) isBlack

Definition at line 544 of file OOColor.m.

387{
388 return rgba[0] == 0.0f && rgba[1] == 0.0f && rgba[2] == 0.0f;
389}

◆ isWhite

- (BOOL) isWhite

Definition at line 544 of file OOColor.m.

393{
394 return rgba[0] == 1.0f && rgba[1] == 1.0f && rgba[2] == 1.0f && rgba[3] == 1.0f;
395}

◆ lightGrayColor

+ (OOColor *) lightGrayColor

Definition at line 544 of file OOColor.m.

251{
252 return [OOColor colorWithWhite:2.0f/3.0f alpha:1.0f];
253}

Referenced by ApplyColor().

+ Here is the caller graph for this function:

◆ magentaColor

+ (OOColor *) magentaColor

Definition at line 544 of file OOColor.m.

299{
300 return [OOColor colorWithRed:1.0f green:0.0f blue:1.0f alpha:1.0f];
301}

◆ normalizedArray

- (NSArray *) normalizedArray

Definition at line 544 of file OOColor.m.

512{
513 float r, g, b, a;
514 [self getRed:&r green:&g blue:&b alpha:&a];
515 return [NSArray arrayWithObjects:
516 [NSNumber numberWithFloat:r],
517 [NSNumber numberWithFloat:g],
518 [NSNumber numberWithFloat:b],
519 [NSNumber numberWithFloat:a],
520 nil];
521}

Referenced by AddColorIfAppropriate(), CanonicalizeMaterialSpecifier(), EquipmentInfoGetProperty(), FlasherGetProperty(), PlayerShipGetProperty(), ShipGetProperty(), SynthSpecular(), and VisualEffectGetProperty().

+ Here is the caller graph for this function:

◆ orangeColor

+ (OOColor *) orangeColor

Definition at line 544 of file OOColor.m.

305{
306 return [OOColor colorWithRed:1.0f green:0.5f blue:0.0f alpha:1.0f];
307}

◆ premultipliedColor

- (OOColor *) premultipliedColor

Definition at line 544 of file OOColor.m.

493{
494 if (rgba[3] == 1.0f) return [[self retain] autorelease];
495 return [OOColor colorWithRed:rgba[0] * rgba[3]
496 green:rgba[1] * rgba[3]
497 blue:rgba[2] * rgba[3]
498 alpha:1.0f];
499}

◆ purpleColor

+ (OOColor *) purpleColor

Definition at line 544 of file OOColor.m.

311{
312 return [OOColor colorWithRed:0.5f green:0.0f blue:0.5f alpha:1.0f];
313}

◆ redColor

+ (OOColor *) redColor

Definition at line 544 of file OOColor.m.

269{
270 return [OOColor colorWithRed:1.0f green:0.0f blue:0.0f alpha:1.0f];
271}

Referenced by HeadUpDisplay::hudDrawReticleOnTarget.

+ Here is the caller graph for this function:

◆ redComponent

- (float) redComponent

Definition at line 544 of file OOColor.m.

351{
352 return rgba[0];
353}

Referenced by AddMacroColorIfAppropriate(), fillSquareImageDataWithCloudTexture(), FloatRGBFromDictColor(), and HeadUpDisplay::hudDrawReticleOnTarget.

+ Here is the caller graph for this function:

◆ rgbaComponents

- (OORGBAComponents) rgbaComponents

Definition at line 544 of file OOColor.m.

380{
381 OORGBAComponents c = { rgba[0], rgba[1], rgba[2], rgba[3] };
382 return c;
383}

Referenced by ModulateColor().

+ Here is the caller graph for this function:

◆ rgbaDescription

- (NSString *) rgbaDescription

Definition at line 544 of file OOColor.m.

525{
527}
NSString * OORGBAComponentsDescription(OORGBAComponents components)
Definition OOColor.m:538
OORGBAComponents rgbaComponents()
Definition OOColor.m:379

◆ saturationComponent

- (float) saturationComponent

Definition at line 544 of file OOColor.m.

426{
427 float maxrgb = (rgba[0] > rgba[1])? ((rgba[0] > rgba[2])? rgba[0]:rgba[2]):((rgba[1] > rgba[2])? rgba[1]:rgba[2]);
428 float minrgb = (rgba[0] < rgba[1])? ((rgba[0] < rgba[2])? rgba[0]:rgba[2]):((rgba[1] < rgba[2])? rgba[1]:rgba[2]);
429 return maxrgb == 0.0f ? 0.0f : (1.0f - (minrgb / maxrgb));
430}

◆ setHue:saturation:brightness:alpha:

- (void) setHue: (float) h
saturation: (float) s
brightness: (float) b
alpha: (float) a 
implementation

Definition at line 544 of file OOColor.m.

42 :(float)h saturation:(float)s brightness:(float)b alpha:(float)a
43{
44 rgba[3] = a;
45 if (s == 0.0f)
46 {
47 rgba[0] = rgba[1] = rgba[2] = b;
48 return;
49 }
50 float f, p, q, t;
51 int i;
52 h = fmod(h, 360.0f);
53 if (h < 0.0) h += 360.0f;
54 h /= 60.0f;
55
56 i = floor(h);
57 f = h - i;
58 p = b * (1.0f - s);
59 q = b * (1.0f - (s * f));
60 t = b * (1.0f - (s * (1.0f - f)));
61
62 switch (i)
63 {
64 case 0:
65 rgba[0] = b; rgba[1] = t; rgba[2] = p; break;
66 case 1:
67 rgba[0] = q; rgba[1] = b; rgba[2] = p; break;
68 case 2:
69 rgba[0] = p; rgba[1] = b; rgba[2] = t; break;
70 case 3:
71 rgba[0] = p; rgba[1] = q; rgba[2] = b; break;
72 case 4:
73 rgba[0] = t; rgba[1] = p; rgba[2] = b; break;
74 case 5:
75 rgba[0] = b; rgba[1] = p; rgba[2] = q; break;
76 }
77}

◆ setRed:green:blue:alpha:

- (void) setRed: (float) r
green: (float) g
blue: (float) b
alpha: (float) a 
implementation

Definition at line 544 of file OOColor.m.

33 :(float)r green:(float)g blue:(float)b alpha:(float)a
34{
35 rgba[0] = r;
36 rgba[1] = g;
37 rgba[2] = b;
38 rgba[3] = a;
39}

◆ whiteColor

+ (OOColor *) whiteColor

Definition at line 544 of file OOColor.m.

257{
258 return [OOColor colorWithWhite:1.0f alpha:1.0f];
259}

◆ yellowColor

+ (OOColor *) yellowColor

Definition at line 544 of file OOColor.m.

293{
294 return [OOColor colorWithRed:1.0f green:1.0f blue:0.0f alpha:1.0f];
295}

Referenced by GuiDisplayGen::addLongText:startingAtRow:align:.

+ Here is the caller graph for this function:

Member Data Documentation

◆ rgba

- (float rgba[4])
private

Definition at line 48 of file OOColor.h.


The documentation for this class was generated from the following files: