Oolite
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]

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 41 of file OOColor.h.

Method Documentation

◆ alphaComponent

- (float) alphaComponent

Definition at line 442 of file OOColor.m.

443{
444 return rgba[3];
445}
float rgba[4]
Definition OOColor.h:43

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:

◆ blackColor

+ (OOColor *) blackColor

Definition at line 234 of file OOColor.m.

235{
236 return [OOColor colorWithWhite:0.0f alpha:1.0f];
237}
OOColor * colorWithWhite:alpha:(float white,[alpha] float alpha)
Definition OOColor.m:114

References blackColor, and colorWithWhite:alpha:.

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

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 309 of file OOColor.m.

309 :(float)fraction ofColor:(OOColor*)color
310{
311 float rgba1[4];
312 [color getRed:&rgba1[0] green:&rgba1[1] blue:&rgba1[2] alpha:&rgba1[3]];
313
314 OOColor* result = [[OOColor alloc] init];
315 [result setRed:OOLerp(rgba[0], rgba1[0], fraction)
316 green:OOLerp(rgba[1], rgba1[1], fraction)
317 blue:OOLerp(rgba[2], rgba1[2], fraction)
318 alpha:OOLerp(rgba[3], rgba1[3], fraction)];
319
320 return [result autorelease];
321}
void getRed:green:blue:alpha:(float *red,[green] float *green,[blue] float *blue,[alpha] float *alpha)
Definition OOColor.m:344
void setRed:green:blue:alpha:(float r, [green] float g, [blue] float b, [alpha] float a)
Definition OOColor.m:32

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

Referenced by SkyEntity::initWithColors:col2: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 269 of file OOColor.m.

270{
271 return [OOColor colorWithRed:0.0f green:0.0f blue:1.0f alpha:1.0f];
272}
OOColor * colorWithRed:green:blue:alpha:(float red,[green] float green,[blue] float blue,[alpha] float alpha)
Definition OOColor.m:107

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

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

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

◆ blueComponent

- (float) blueComponent

Definition at line 339 of file OOColor.m.

340{
341 return rgba[2];
342}

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 202 of file OOColor.m.

202 :(id)description
203{
204 OOColor* color = [OOColor colorWithDescription:description];
205 if (color == nil || 0.5f <= [color brightnessComponent])
206 return color;
207
208 return [OOColor colorWithHue:[color hueComponent] / 360.0f saturation:[color saturationComponent] brightness:0.5f alpha:1.0f];
209}
return nil
float saturationComponent()
Definition OOColor.m:390
OOColor * colorWithDescription:(id description)
Definition OOColor.m:135
float hueComponent()
Definition OOColor.m:371
OOColor * colorWithHue:saturation:brightness:alpha:(float hue,[saturation] float saturation,[brightness] float brightness,[alpha] float alpha)
Definition OOColor.m:100
float brightnessComponent()
Definition OOColor.m:397

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 397 of file OOColor.m.

398{
399 float maxrgb = (rgba[0] > rgba[1]) ? ((rgba[0] > rgba[2]) ? rgba[0] : rgba[2]) : ((rgba[1] > rgba[2]) ? rgba[1] : rgba[2]);
400 return maxrgb;
401}

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 299 of file OOColor.m.

300{
301 return [OOColor colorWithRed:0.6f green:0.4f blue:0.2f alpha:1.0f];
302}

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 304 of file OOColor.m.

305{
306 return [OOColor colorWithWhite:0.0f alpha:0.0f];
307}

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 211 of file OOColor.m.

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

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 457 of file OOColor.m.

457 :(float)factor
458{
459 return [OOColor colorWithRed:OOClamp_0_1_f(rgba[0] * factor)
460 green:OOClamp_0_1_f(rgba[1] * factor)
461 blue:OOClamp_0_1_f(rgba[2] * factor)
462 alpha:rgba[3]];
463}

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 135 of file OOColor.m.

135 :(id)description
136{
137 return [self colorWithDescription:description saturationFactor:1.0f];
138}

References colorWithDescription:saturationFactor:.

Referenced by brightColorWithDescription:, CanonicalizeMaterialSpecifier(), SkyEntity::changeProperty:withDictionary:, GuiDisplayGen::colorFromSetting:defaultValue:, PlayerEntity::dialCustomColor:, GuiDisplayGen(Internal)::drawAdvancedNavArrayAtX:y:z:alpha:usingRoute:optimizedBy:zoom:, HeadUpDisplay(Private)::drawMultiFunctionDisplay:withText:asIndex:, GuiDisplayGen(Internal)::drawStarChart:y:z:alpha:compact:, HeadUpDisplay(Private)::drawSurround:, GuiDisplayGen(Internal)::drawSystemMarker:atX:andY:andZ:withAlpha:andScale:, EquipmentInfoSetProperty(), EquipmentInfoSetProperty(), FlasherSetProperty(), FlasherSetProperty(), FloatRGBFromDictColor(), GetRGBAArrayFromInfo(), GlobalSetGuiColorSettingForKey(), GlobalSetGuiColorSettingForKey(), PlanetEntity(OOPrivate)::initAsAtmosphereForPlanet:dictionary:, SkyEntity::initWithColors:col2:andSystemInfo:, HeadUpDisplay::initWithDictionary:inFile:, OOEquipmentType(Private)::initWithInfo:, OOBasicMaterial::initWithName:configuration:, 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(), PlanetSetProperty(), PlayerShipSetProperty(), 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(), ShipSetProperty(), OOShipRegistry(OODataLoader)::validateNewStyleFlasherDeclaration:forShip:fatalError:, VisualEffectSetProperty(), 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 140 of file OOColor.m.

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

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 127 of file OOColor.m.

127 :(OOHSBAComponents)components
128{
129 return [self colorWithHue:components.h / 360.0f
130 saturation:components.s
131 brightness:components.b
132 alpha:components.a];
133}

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 100 of file OOColor.m.

100 :(float)hue saturation:(float)saturation brightness:(float)brightness alpha:(float)alpha
101{
102 OOColor* result = [[OOColor alloc] init];
103 [result setHue:360.0f * hue saturation:saturation brightness:brightness alpha:alpha];
104 return [result autorelease];
105}
void setHue:saturation:brightness:alpha:(float h, [saturation] float s, [brightness] float b, [alpha] float a)
Definition OOColor.m:40

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 107 of file OOColor.m.

107 :(float)red green:(float)green blue:(float)blue alpha:(float)alpha
108{
109 OOColor* result = [[OOColor alloc] init];
110 [result setRed:red green:green blue:blue alpha:alpha];
111 return [result autorelease];
112}

References setRed:green:blue:alpha:.

Referenced by OOBasicMaterial::ambientColor, blueColor, brownColor, OOFlasherEntity::color, colorFromString:, colorWithBrightnessFactor:, colorWithDescription:saturationFactor:, colorWithRGBAComponents:, colorWithWhite:alpha:, cyanColor, OOBasicMaterial::diffuseColor, GuiDisplayGen(Internal)::drawStarChart:y:z:alpha:compact:, 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 119 of file OOColor.m.

119 :(OORGBAComponents)components
120{
121 return [self colorWithRed:components.r
122 green:components.g
123 blue:components.b
124 alpha:components.a];
125}

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 114 of file OOColor.m.

114 :(float)white alpha:(float)alpha
115{
116 return [OOColor colorWithRed:white green:white blue:white alpha:alpha];
117}

References colorWithRed:green:blue:alpha:.

Referenced by blackColor, clearColor, darkGrayColor, GuiDisplayGen(Internal)::drawAdvancedNavArrayAtX:y:z:alpha:usingRoute:optimizedBy:zoom:, GuiDisplayGen(Internal)::drawGLDisplay:y:z:alpha:, GuiDisplayGen(Internal)::drawStarChart:y:z:alpha:compact:, 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 94 of file OOColor.m.

94 :(NSZone*)zone
95{
96 // Copy is implemented as retain since OOColor is immutable.
97 return [self retain];
98}

◆ cyanColor

◆ darkGrayColor

+ (OOColor *) darkGrayColor

Definition at line 239 of file OOColor.m.

240{
241 return [OOColor colorWithWhite:1.0f / 3.0f alpha:1.0f];
242}

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 323 of file OOColor.m.

324{
325 return [NSString stringWithFormat:@"%g, %g, %g, %g", rgba[0], rgba[1], rgba[2], rgba[3]];
326}

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 403 of file OOColor.m.

403 :(float*)hue saturation:(float*)saturation brightness:(float*)brightness alpha:(float*)alpha
404{
405 NSParameterAssert(hue != NULL && saturation != NULL && brightness != NULL && alpha != NULL);
406
407 *alpha = rgba[3];
408
409 float fRed = rgba[0], fGreen = rgba[1], fBlue = rgba[2];
410 float maxrgb = fmax(fRed, fmax(fGreen, fBlue));
411 float minrgb = fmin(fRed, fmin(fGreen, fBlue));
412 float delta = maxrgb - minrgb + 0.0001f;
413 float h = 0.0f;
414 if (maxrgb == fRed && fGreen >= fBlue) {
415 h = 60.0f * (fGreen - fBlue) / delta;
416 } else if (maxrgb == fRed && fGreen < fBlue) {
417 h = 60.0f * (fGreen - fBlue) / delta + 360.0f;
418 } else if (maxrgb == fGreen) {
419 h = 60.0f * (fBlue - fRed) / delta + 120.0f;
420 } else if (maxrgb == fBlue) {
421 h = 60.0f * (fRed - fGreen) / delta + 240.0f;
422 }
423
424 float s = (maxrgb == 0.0f) ? 0.0f : (1.0f - (minrgb / maxrgb));
425
426 *hue = h;
427 *saturation = s;
428 *brightness = maxrgb;
429}

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 344 of file OOColor.m.

344 :(float*)red green:(float*)green blue:(float*)blue alpha:(float*)alpha
345{
346 NSParameterAssert(red != NULL && green != NULL && blue != NULL && alpha != NULL);
347
348 *red = rgba[0];
349 *green = rgba[1];
350 *blue = rgba[2];
351 *alpha = rgba[3];
352}

References rgba.

Referenced by blendedColorWithFraction:ofColor:, GuiDisplayGen(Internal)::drawAdvancedNavArrayAtX:y:z:alpha:usingRoute:optimizedBy:zoom:, HeadUpDisplay(Private)::drawCustomLight:, HeadUpDisplay(Private)::drawMultiFunctionDisplay:withText:asIndex:, GuiDisplayGen(Internal)::drawStarChart:y:z:alpha:compact:, GetRGBAArrayFromInfo(), PlanetEntity(OOPrivate)::initAsAtmosphereForPlanet:dictionary:, OOSparkEntity::initWithPosition:velocity:duration:size:color:, normalizedArray, ShipEntity::scannerDisplayColorForShip:isHostile:flash:scannerDisplayColor1:scannerDisplayColor2:scannerDisplayColorH1:scannerDisplayColorH2:, OOVisualEffectEntity::scannerDisplayColorForShip:scannerDisplayColor1:scannerDisplayColor2:, 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 254 of file OOColor.m.

255{
256 return [OOColor colorWithWhite:0.5f alpha:1.0f];
257}

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 264 of file OOColor.m.

265{
266 return [OOColor colorWithRed:0.0f green:1.0f blue:0.0f alpha:1.0f];
267}

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:y:z:alpha:compact:, 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 334 of file OOColor.m.

335{
336 return rgba[1];
337}

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 431 of file OOColor.m.

432{
433 OOHSBAComponents c;
434 [self getHue:&c.h
435 saturation:&c.s
436 brightness:&c.b
437 alpha:&c.a];
438 return c;
439}

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 482 of file OOColor.m.

483{
485}
NSString * OOHSBAComponentsDescription(OOHSBAComponents components)
Definition OOColor.m:494
OOHSBAComponents hsbaComponents()
Definition OOColor.m:431

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 371 of file OOColor.m.

372{
373 float maxrgb = (rgba[0] > rgba[1]) ? ((rgba[0] > rgba[2]) ? rgba[0] : rgba[2]) : ((rgba[1] > rgba[2]) ? rgba[1] : rgba[2]);
374 float minrgb = (rgba[0] < rgba[1]) ? ((rgba[0] < rgba[2]) ? rgba[0] : rgba[2]) : ((rgba[1] < rgba[2]) ? rgba[1] : rgba[2]);
375 float delta = maxrgb - minrgb + 0.0001f;
376 float fRed = rgba[0], fGreen = rgba[1], fBlue = rgba[2];
377 float hue = 0.0f;
378 if (maxrgb == fRed && fGreen >= fBlue) {
379 hue = 60.0f * (fGreen - fBlue) / delta;
380 } else if (maxrgb == fRed && fGreen < fBlue) {
381 hue = 60.0f * (fGreen - fBlue) / delta + 360.0f;
382 } else if (maxrgb == fGreen) {
383 hue = 60.0f * (fBlue - fRed) / delta + 120.0f;
384 } else if (maxrgb == fBlue) {
385 hue = 60.0f * (fRed - fGreen) / delta + 240.0f;
386 }
387 return hue;
388}

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 360 of file OOColor.m.

361{
362 return rgba[0] == 0.0f && rgba[1] == 0.0f && rgba[2] == 0.0f;
363}

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 365 of file OOColor.m.

366{
367 return rgba[0] == 1.0f && rgba[1] == 1.0f && rgba[2] == 1.0f && rgba[3] == 1.0f;
368}

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 244 of file OOColor.m.

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

References colorWithWhite:alpha:, and lightGrayColor.

Referenced by lightGrayColor.

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

◆ magentaColor

+ (OOColor *) magentaColor

Definition at line 284 of file OOColor.m.

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

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 465 of file OOColor.m.

466{
467 float r, g, b, a;
468 [self getRed:&r green:&g blue:&b alpha:&a];
469 return [NSArray arrayWithObjects:
470 [NSNumber numberWithFloat:r],
471 [NSNumber numberWithFloat:g],
472 [NSNumber numberWithFloat:b],
473 [NSNumber numberWithFloat:a],
474 nil];
475}

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

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

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

◆ orangeColor

+ (OOColor *) orangeColor

Definition at line 289 of file OOColor.m.

290{
291 return [OOColor colorWithRed:1.0f green:0.5f blue:0.0f alpha:1.0f];
292}

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 447 of file OOColor.m.

448{
449 if (rgba[3] == 1.0f)
450 return [[self retain] autorelease];
451 return [OOColor colorWithRed:rgba[0] * rgba[3]
452 green:rgba[1] * rgba[3]
453 blue:rgba[2] * rgba[3]
454 alpha:1.0f];
455}

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 294 of file OOColor.m.

295{
296 return [OOColor colorWithRed:0.5f green:0.0f blue:0.5f alpha:1.0f];
297}

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 259 of file OOColor.m.

260{
261 return [OOColor colorWithRed:1.0f green:0.0f blue:0.0f alpha:1.0f];
262}

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

Referenced by OOOXZManager(NSURLConnectionDataDelegate)::colorForManifest:, GuiDisplayGen(Internal)::drawGLDisplay:y:z:alpha:, GuiDisplayGen(Internal)::drawStarChart:y:z:alpha:compact:, 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 329 of file OOColor.m.

330{
331 return rgba[0];
332}

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 354 of file OOColor.m.

355{
356 OORGBAComponents c = { rgba[0], rgba[1], rgba[2], rgba[3] };
357 return c;
358}

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 477 of file OOColor.m.

478{
480}
NSString * OORGBAComponentsDescription(OORGBAComponents components)
Definition OOColor.m:489
OORGBAComponents rgbaComponents()
Definition OOColor.m:354

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 390 of file OOColor.m.

391{
392 float maxrgb = (rgba[0] > rgba[1]) ? ((rgba[0] > rgba[2]) ? rgba[0] : rgba[2]) : ((rgba[1] > rgba[2]) ? rgba[1] : rgba[2]);
393 float minrgb = (rgba[0] < rgba[1]) ? ((rgba[0] < rgba[2]) ? rgba[0] : rgba[2]) : ((rgba[1] < rgba[2]) ? rgba[1] : rgba[2]);
394 return maxrgb == 0.0f ? 0.0f : (1.0f - (minrgb / maxrgb));
395}

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 40 of file OOColor.m.

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

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 32 of file OOColor.m.

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

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 249 of file OOColor.m.

250{
251 return [OOColor colorWithWhite:1.0f alpha:1.0f];
252}

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: