Oolite 1.91.0.7658-250404-b1488af
All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
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 486 of file OOColor.m.

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

References alphaComponent, and rgba.

Referenced by AddMacroColorIfAppropriate(), alphaComponent, HeadUpDisplay(Private)::drawDirectionCue:, fillSquareImageDataWithCloudTexture(), HeadUpDisplay::hudDrawReticleOnTarget, OOBasicMaterial::setAmbientColor:, OOBasicMaterial::setDiffuseColor:, OOBasicMaterial::setEmissionColor:, OOBasicMaterial::setSpecularColor:, and OOSunEntity::setSunColor:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ asNSColor

- (NSColor *) asNSColor

Provided by category OOColor(NSColorConversion).

Definition at line 35 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}

Referenced by NSColor(OOColorConversion)::colorWithOOColorDescription:.

+ Here is the caller graph for this function:

◆ blackColor

+ (OOColor *) blackColor

Definition at line 238 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

References blackColor, and colorWithWhite:alpha:.

Referenced by blackColor, and GuiDisplayGen(Internal)::drawGLDisplay:x:y:z:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ blendedColorWithFraction:ofColor:

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

Definition at line 328 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

References getRed:green:blue:alpha:, and setRed:green:blue:alpha:.

Referenced by SkyEntity::initWithColors:col1:andSystemInfo:, SaturatedColorInRange(), OOSunEntity::setSunColor:, Universe::setSystemDataForGalaxy:planet:key:value:fromManifest:forLayer:, Universe::setUpSpace, and OOSkyDrawable(OOPrivate)::setUpStarsWithColor1:color2:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ blueColor

+ (OOColor *) blueColor

Definition at line 280 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

References blueColor, and colorWithRed:green:blue:alpha:.

Referenced by blueColor, OOOXZManager(NSURLConnectionDataDelegate)::colorForManifest:, and GuiDisplayGen(Internal)::drawStarChart:x:y:z:alpha:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ blueComponent

- (float) blueComponent

Definition at line 362 of file OOColor.m.

363{
364 return rgba[2];
365}

References blueComponent, and rgba.

Referenced by AddMacroColorIfAppropriate(), blueComponent, HeadUpDisplay(Private)::drawDirectionCue:, HeadUpDisplay(Private)::drawSurround:, fillSquareImageDataWithCloudTexture(), FloatRGBFromDictColor(), HeadUpDisplay::hudDrawReticleOnTarget, PlanetEntity::initFromDictionary:withAtmosphere:andSeed:, OOBasicMaterial::setAmbientColor:, OOLaserShotEntity::setColor:, OOBasicMaterial::setDiffuseColor:, OOBasicMaterial::setEmissionColor:, OOBasicMaterial::setSpecularColor:, OOSunEntity::setSunColor:, and PlanetEntity(OOPrivate)::setTextureColorForPlanet:inSystem:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ brightColorWithDescription:

+ (OOColor *) brightColorWithDescription: (id) description

Definition at line 205 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

References brightnessComponent, colorWithDescription:, colorWithHue:saturation:brightness:alpha:, hueComponent, nil, and saturationComponent.

Referenced by Universe::setSystemDataForGalaxy:planet:key:value:fromManifest:forLayer:, and OOEquipmentType::weaponColor.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ brightnessComponent

- (float) brightnessComponent

Definition at line 432 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}

References brightnessComponent, and rgba.

Referenced by brightColorWithDescription:, and brightnessComponent.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ brownColor

+ (OOColor *) brownColor

Definition at line 316 of file OOColor.m.

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

References brownColor, and colorWithRed:green:blue:alpha:.

Referenced by brownColor, and OOOXZManager(NSURLConnectionDataDelegate)::colorForManifest:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearColor

+ (OOColor *) clearColor

Definition at line 322 of file OOColor.m.

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

References clearColor, and colorWithWhite:alpha:.

Referenced by clearColor.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ colorFromString:

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

Definition at line 214 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}

References colorWithRed:green:blue:alpha:, and nil.

Referenced by colorWithDescription:saturationFactor:, HeadUpDisplay(Private)::resetGui:withInfo:, and HeadUpDisplay::resetGuis:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ colorWithBrightnessFactor:

- (OOColor *) colorWithBrightnessFactor: (float) factor

Definition at line 502 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}

References colorWithRed:green:blue:alpha:.

Referenced by OOSkyDrawable(OOPrivate)::setUpNebulaeWithColor1:color2:clusterFactor:nebulaHueFix:alpha:scale:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ colorWithDescription:

+ (OOColor *) colorWithDescription: (id) description

Definition at line 127 of file OOColor.m.

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

References colorWithDescription:saturationFactor:.

Referenced by brightColorWithDescription:, CanonicalizeMaterialSpecifier(), SkyEntity::changeProperty:withDictionary:, GuiDisplayGen::colorFromSetting:defaultValue:, NSColor(OOColorConversion)::colorWithOOColorDescription:, PlayerEntity::dialCustomColor:, GuiDisplayGen(Internal)::drawAdvancedNavArrayAtX:y:z:alpha:usingRoute:optimizedBy:zoom:, HeadUpDisplay(Private)::drawMultiFunctionDisplay:withText:asIndex:, GuiDisplayGen(Internal)::drawStarChart:x:y:z:alpha:, HeadUpDisplay(Private)::drawSurround:, GuiDisplayGen(Internal)::drawSystemMarker:atX:andY:andZ:withAlpha:andScale:, EquipmentInfoSetProperty(), FlasherSetProperty(), FloatRGBFromDictColor(), GetRGBAArrayFromInfo(), GlobalSetGuiColorSettingForKey(), PlanetEntity(OOPrivate)::initAsAtmosphereForPlanet:dictionary:, SkyEntity::initWithColors:col1:andSystemInfo:, HeadUpDisplay::initWithDictionary:inFile:, OOEquipmentType(Private)::initWithInfo:, OOBasicMaterial::initWithName:configuration:, OODebugMonitor(Private)::normalizeConfigValue:forKey:, PlayerEntity::noteGUIDidChangeFrom:to:refresh:, NSDictionary(OOMateralProperties)::oo_ambientColor, NSDictionary(OOMateralProperties)::oo_diffuseColor, NSDictionary(OOMateralProperties)::oo_emissionColor, NSDictionary(OOMateralProperties)::oo_emissionModulateColor, NSDictionary(OOMateralProperties)::oo_illuminationModulateColor, NSDictionary(OOMateralProperties)::oo_specularColor, NSDictionary(OOMateralProperties)::oo_specularModulateColor, PlanetSetProperty(), PlayerShipSetProperty(), SkyEntity(OOPrivate)::readColor1:andColor2:andColor3:andColor4:fromDictionary:, HeadUpDisplay::resetGuis:, SetGLColourFromInfo(), PlayerEntity(Scripting)::setMissionChoicesDictionary:, OOVisualEffectEntity::setScannerDisplayColor1:, ShipEntity::setScannerDisplayColor1:, OOVisualEffectEntity::setScannerDisplayColor2:, ShipEntity::setScannerDisplayColor2:, ShipEntity::setScannerDisplayColorHostile1:, ShipEntity::setScannerDisplayColorHostile2:, Universe::setSystemDataForGalaxy:planet:key:value:fromManifest:forLayer:, Universe::setUpBreakPattern:orientation:forDocking:, Universe::setUpSettings, Universe::setUpSpace, ShipSetProperty(), OOShipRegistry(OODataLoader)::validateNewStyleFlasherDeclaration:forShip:fatalError:, and VisualEffectSetProperty().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ colorWithDescription:saturationFactor:

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

Definition at line 133 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

References colorFromString:, colorWithHue:saturation:brightness:alpha:, colorWithRed:green:blue:alpha:, getHue:saturation:brightness:alpha:, and nil.

Referenced by colorWithDescription:, and OOFlasherEntity(Internal)::setUpColors:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ colorWithHSBAComponents:

+ (OOColor *) colorWithHSBAComponents: (OOHSBAComponents) components

Definition at line 118 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}

References colorWithHue:saturation:brightness:alpha:.

+ Here is the call graph for this function:

◆ colorWithHue:saturation:brightness:alpha:

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

Definition at line 87 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

References setHue:saturation:brightness:alpha:.

Referenced by brightColorWithDescription:, colorWithDescription:saturationFactor:, colorWithHSBAComponents:, PlanetEntity::initFromDictionary:withAtmosphere:andSeed:, SaturatedColorInRange(), ShipEntity::setCommsMessageColor, OOSunEntity::setSunColor:, PlanetEntity(OOPrivate)::setTextureColorForPlanet:inSystem:, Universe::setUpSpace, and ShipEntity::throwSparks.

+ Here is the call graph for this function:
+ 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 95 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}

References setRed:green:blue:alpha:.

Referenced by OOBasicMaterial::ambientColor, NSColor(OOColorConversion)::asOOColor, blueColor, brownColor, OOFlasherEntity::color, colorFromString:, colorWithBrightnessFactor:, colorWithDescription:saturationFactor:, colorWithRGBAComponents:, colorWithWhite:alpha:, cyanColor, OOBasicMaterial::diffuseColor, GuiDisplayGen(Internal)::drawStarChart:x:y:z:alpha:, Universe::drawUniverse, OOBasicMaterial::emmisionColor, greenColor, DustEntity::init, Entity::init, PlanetEntity(OOPrivate)::initAsAtmosphereForPlanet:dictionary:, magentaColor, HeadUpDisplay::OODrawPlanetInfo, orangeColor, premultipliedColor, purpleColor, SkyEntity(OOPrivate)::readColor1:andColor2:andColor3:andColor4:fromDictionary:, redColor, HeadUpDisplay::resetGuis:, PlayerEntity::setGuiToEquipShipScreen:selectingFacingFor:, OOSunEntity::setSunColor:, Universe::setUpBreakPattern:orientation:forDocking:, Universe::setUpWitchspaceBetweenSystem:andSystem:, OOBasicMaterial::specularColor, and yellowColor.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ colorWithRGBAComponents:

+ (OOColor *) colorWithRGBAComponents: (OORGBAComponents) components

Definition at line 109 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}

References colorWithRed:green:blue:alpha:.

Referenced by ModulateColor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ colorWithWhite:alpha:

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

Definition at line 103 of file OOColor.m.

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

References colorWithRed:green:blue:alpha:.

Referenced by blackColor, clearColor, darkGrayColor, GuiDisplayGen(Internal)::drawAdvancedNavArrayAtX:y:z:alpha:usingRoute:optimizedBy:zoom:, GuiDisplayGen(Internal)::drawGLDisplay:x:y:z:, GuiDisplayGen(Internal)::drawStarChart:x:y:z:alpha:, grayColor, lightGrayColor, NSDictionary(OOMateralProperties)::oo_specularColor, and whiteColor.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copyWithZone:

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

Definition at line 80 of file OOColor.m.

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

◆ cyanColor

◆ darkGrayColor

+ (OOColor *) darkGrayColor

Definition at line 244 of file OOColor.m.

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

References colorWithWhite:alpha:, and darkGrayColor.

Referenced by darkGrayColor, PlayerEntity(Contracts)::setGuiToManifestScreen, and PlayerEntity(Scripting)::setMissionChoicesDictionary:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ descriptionComponents

- (NSString *) descriptionComponents
implementation

Definition at line 343 of file OOColor.m.

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

References descriptionComponents.

Referenced by descriptionComponents.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHue:saturation:brightness:alpha:

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

Definition at line 438 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}

References rgba.

Referenced by colorWithDescription:saturationFactor:, hsbaComponents, SaturatedColorInRange(), and OOSunEntity::setSunColor:.

+ 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 368 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}

References rgba.

Referenced by ApplyColor(), OOColor(NSColorConversion)::asNSColor, blendedColorWithFraction:ofColor:, GuiDisplayGen(Internal)::drawAdvancedNavArrayAtX:y:z:alpha:usingRoute:optimizedBy:zoom:, HeadUpDisplay(Private)::drawCustomLight:, HeadUpDisplay(Private)::drawMultiFunctionDisplay:withText:asIndex:, GuiDisplayGen(Internal)::drawStarChart:x:y:z:alpha:, GetRGBAArrayFromInfo(), PlanetEntity(OOPrivate)::initAsAtmosphereForPlanet:dictionary:, OOSparkEntity::initWithPosition:velocity:duration:size:color:, normalizedArray, OOVisualEffectEntity::scannerDisplayColorForShip:flash:scannerDisplayColor1:, ShipEntity::scannerDisplayColorForShip:otherShip:isHostile:flash:scannerDisplayColor1:scannerDisplayColor2:scannerDisplayColorH1:, OOLightParticleEntity::setColor:, DustEntity::setDustColor:, GuiDisplayGen::setGLColorFromSetting:defaultValue:alpha:, SetGLColourFromInfo(), OOBreakPatternEntity::setInnerColor:outerColor:, Universe::setLighting, OOSunEntity::setSunColor:, OOCrosshairs(Private)::setUpDataWithPoints:scale:color:overallAlpha:, OOExhaustPlumeEntity::update:, OODefaultShaderSynthesizer::writeDiffuseColorTermIfNeeded, and OODefaultShaderSynthesizer::writeSpecularLighting.

+ Here is the caller graph for this function:

◆ grayColor

+ (OOColor *) grayColor

Definition at line 262 of file OOColor.m.

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

References colorWithWhite:alpha:, and grayColor.

Referenced by OOOXZManager(NSURLConnectionDataDelegate)::colorForManifest:, grayColor, OOOXZManager::gui, PlayerEntity::setGuiToGameOptionsScreen, PlayerEntity::setGuiToLoadSaveScreen, and PlayerEntity::setupStartScreenGui.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ greenColor

+ (OOColor *) greenColor

Definition at line 274 of file OOColor.m.

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

References colorWithRed:green:blue:alpha:, and greenColor.

Referenced by PlayerEntity(Contracts)::buySelectedShip, PlayerEntity(StickMapperInternal)::displayFunctionList:skip:, PlayerEntity(KeyMapperInternal)::displayKeyboardLayoutList:skip:, PlayerEntity(KeyMapperInternal)::displayKeyFunctionList:skip:, GuiDisplayGen(Internal)::drawEquipmentList:z:, GuiDisplayGen(Internal)::drawStarChart:x:y:z:alpha:, greenColor, OOOXZManager::gui, HeadUpDisplay::hudDrawReticleOnTarget, HeadUpDisplay::initWithDictionary:inFile:, GuiDisplayGen::initWithPixelSize:columns:rows:rowHeight:rowStart:title:, PlayerEntity(OOLoadSavePrivate)::lsCommanders:directory:pageNumber:highlightName:, OOOXZManager::processShowInfoKey, HeadUpDisplay::resetGuis:, GuiDisplayGen::resizeTo:characterHeight:title:, ShipEntity::setCommsMessageColor, PlayerEntity::setGuiToEquipShipScreen:selectingFacingFor:, PlayerEntity::setGuiToInterfacesScreen:, PlayerEntity(KeyMapper)::setGuiToKeyConfigScreen:, PlayerEntity(Contracts)::setGuiToManifestScreen, PlayerEntity::setGuiToMarketScreen, PlayerEntity(LoadSave)::setGuiToScenarioScreen:, PlayerEntity(Contracts)::setGuiToShipyardScreen:, PlayerEntity::setGuiToSystemDataScreenRefreshBackground:, Universe(OOPrivate)::setLibraryTextForDemoShip, PlayerEntity::showInformationForSelectedInterface, PlayerEntity::showInformationForSelectedUpgradeWithFormatString:, OOOXZManager::showInstallOptions, PlayerEntity(OOPrivate)::showMarketScreenHeaders, OOOXZManager::showRemoveOptions, and PlayerEntity(Contracts)::showShipyardInfoForSelection.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ greenComponent

- (float) greenComponent

Definition at line 356 of file OOColor.m.

357{
358 return rgba[1];
359}

References greenComponent, and rgba.

Referenced by AddMacroColorIfAppropriate(), HeadUpDisplay(Private)::drawDirectionCue:, HeadUpDisplay(Private)::drawSurround:, fillSquareImageDataWithCloudTexture(), FloatRGBFromDictColor(), greenComponent, HeadUpDisplay::hudDrawReticleOnTarget, PlanetEntity::initFromDictionary:withAtmosphere:andSeed:, OOBasicMaterial::setAmbientColor:, OOLaserShotEntity::setColor:, OOBasicMaterial::setDiffuseColor:, OOBasicMaterial::setEmissionColor:, OOBasicMaterial::setSpecularColor:, OOSunEntity::setSunColor:, and PlanetEntity(OOPrivate)::setTextureColorForPlanet:inSystem:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hsbaComponents

- (OOHSBAComponents) hsbaComponents

Definition at line 474 of file OOColor.m.

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

References getHue:saturation:brightness:alpha:, and hsbaComponents.

Referenced by hsbaComponents, and hsbaDescription.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hsbaDescription

- (NSString *) hsbaDescription

Definition at line 530 of file OOColor.m.

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

References hsbaComponents, hsbaDescription, and OOHSBAComponentsDescription().

Referenced by hsbaDescription.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hueComponent

- (float) hueComponent

Definition at line 399 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}

References hueComponent, and rgba.

Referenced by brightColorWithDescription:, and hueComponent.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isBlack

- (BOOL) isBlack

Definition at line 386 of file OOColor.m.

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

References isBlack, and rgba.

Referenced by isBlack.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isWhite

- (BOOL) isWhite

Definition at line 392 of file OOColor.m.

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

References isWhite, and rgba.

Referenced by isWhite.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lightGrayColor

+ (OOColor *) lightGrayColor

Definition at line 250 of file OOColor.m.

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

References colorWithWhite:alpha:, and lightGrayColor.

Referenced by ApplyColor(), and lightGrayColor.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ magentaColor

+ (OOColor *) magentaColor

Definition at line 298 of file OOColor.m.

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

References colorWithRed:green:blue:alpha:, and magentaColor.

Referenced by magentaColor, PlayerEntity::setGuiToIntroFirstGo:, and StickProfileScreen(StickProfileInternal)::showScreen.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ normalizedArray

- (NSArray *) normalizedArray

Definition at line 511 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}

References getRed:green:blue:alpha:, and normalizedArray.

Referenced by AddColorIfAppropriate(), CanonicalizeMaterialSpecifier(), EquipmentInfoGetProperty(), FlasherGetProperty(), OODebugMonitor(Private)::normalizeConfigValue:forKey:, normalizedArray, PlayerShipGetProperty(), ShipGetProperty(), SynthSpecular(), OOShipRegistry(OODataLoader)::validateNewStyleFlasherDeclaration:forShip:fatalError:, and VisualEffectGetProperty().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ orangeColor

+ (OOColor *) orangeColor

Definition at line 304 of file OOColor.m.

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

References colorWithRed:green:blue:alpha:, and orangeColor.

Referenced by OOOXZManager(NSURLConnectionDataDelegate)::colorForManifest:, PlayerEntity(KeyMapperInternal)::displayKeyFunctionList:skip:, GuiDisplayGen(Internal)::drawEquipmentList:z:, OOOXZManager::gui, PlayerEntity(OOLoadSavePrivate)::lsCommanders:directory:pageNumber:highlightName:, orangeColor, OOOXZManager::refreshTextInput:, PlayerEntity::setGuiToEquipShipScreen:selectingFacingFor:, PlayerEntity::setGuiToIntroFirstGo:, PlayerEntity(KeyMapper)::setGuiToKeyConfigScreen:, and PlayerEntity(OOLoadSavePrivate)::showCommanderShip:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ premultipliedColor

- (OOColor *) premultipliedColor

Definition at line 492 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}

References colorWithRed:green:blue:alpha:, premultipliedColor, and rgba.

Referenced by premultipliedColor, and SkyEntity(OOPrivate)::readColor1:andColor2:andColor3:andColor4:fromDictionary:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ purpleColor

+ (OOColor *) purpleColor

Definition at line 310 of file OOColor.m.

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

References colorWithRed:green:blue:alpha:, and purpleColor.

Referenced by purpleColor.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ redColor

+ (OOColor *) redColor

Definition at line 268 of file OOColor.m.

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

References colorWithRed:green:blue:alpha:, and redColor.

Referenced by OOOXZManager(NSURLConnectionDataDelegate)::colorForManifest:, GuiDisplayGen(Internal)::drawGLDisplay:x:y:z:, GuiDisplayGen(Internal)::drawStarChart:x:y:z:alpha:, HeadUpDisplay::hudDrawReticleOnTarget, HeadUpDisplay::initWithDictionary:inFile:, OOPlasmaBurstEntity::initWithPosition:, PlayerEntity(OOLoadSavePrivate)::lsCommanders:directory:pageNumber:highlightName:, redColor, PlayerEntity::setGuiToIntroFirstGo:, PlayerEntity(KeyMapper)::setGuiToKeyMapperScreen:resetCurrentRow:, and PlayerEntity(LoadSave)::setGuiToScenarioScreen:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ redComponent

- (float) redComponent

Definition at line 350 of file OOColor.m.

351{
352 return rgba[0];
353}

References redComponent, and rgba.

Referenced by AddMacroColorIfAppropriate(), HeadUpDisplay(Private)::drawDirectionCue:, HeadUpDisplay(Private)::drawSurround:, fillSquareImageDataWithCloudTexture(), FloatRGBFromDictColor(), HeadUpDisplay::hudDrawReticleOnTarget, PlanetEntity::initFromDictionary:withAtmosphere:andSeed:, redComponent, OOBasicMaterial::setAmbientColor:, OOLaserShotEntity::setColor:, OOBasicMaterial::setDiffuseColor:, OOBasicMaterial::setEmissionColor:, OOBasicMaterial::setSpecularColor:, OOSunEntity::setSunColor:, and PlanetEntity(OOPrivate)::setTextureColorForPlanet:inSystem:.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rgbaComponents

- (OORGBAComponents) rgbaComponents

Definition at line 379 of file OOColor.m.

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

References rgba, and rgbaComponents.

Referenced by GuiDisplayGen(Internal)::drawSystemMarker:atX:andY:andZ:withAlpha:andScale:, GuiDisplayGen::getLastLines, ModulateColor(), rgbaComponents, and rgbaDescription.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rgbaDescription

- (NSString *) rgbaDescription

Definition at line 524 of file OOColor.m.

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

References OORGBAComponentsDescription(), rgbaComponents, and rgbaDescription.

Referenced by OOCombinedEmissionMapGenerator::descriptionComponents, and rgbaDescription.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saturationComponent

- (float) saturationComponent

Definition at line 425 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}

References rgba, and saturationComponent.

Referenced by brightColorWithDescription:, and saturationComponent.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHue:saturation:brightness:alpha:

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

Definition at line 42 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}

References rgba.

Referenced by colorWithHue:saturation:brightness:alpha:.

+ Here is the caller graph for this function:

◆ setRed:green:blue:alpha:

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

Definition at line 33 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}

References rgba.

Referenced by blendedColorWithFraction:ofColor:, and colorWithRed:green:blue:alpha:.

+ Here is the caller graph for this function:

◆ whiteColor

+ (OOColor *) whiteColor

Definition at line 256 of file OOColor.m.

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

References colorWithWhite:alpha:, and whiteColor.

Referenced by OOOXZManager(NSURLConnectionDataDelegate)::colorForManifest:, NSDictionary(OOMateralProperties)::oo_specularModulateColor, Universe::resetCommsLogColor, HeadUpDisplay::resetGuis:, Universe(OOPrivate)::setLibraryTextForDemoShip, OOSunEntity::setSunColor:, Universe::setSystemDataForGalaxy:planet:key:value:fromManifest:forLayer:, Universe::setUpSpace, PlayerEntity::setupStartScreenGui, Universe::setUpUniverseFromWitchspace, whiteColor, and OODefaultShaderSynthesizer::writeDiffuseColorTermIfNeeded.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ yellowColor

Member Data Documentation

◆ rgba


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