5 #ifndef __COLOR_H_INCLUDED__ 6 #define __COLOR_H_INCLUDED__ 177 return (
u16)((
a & 0x80) << 8 |
204 return (
u16)(0x8000 |
205 (
color & 0x00F80000) >> 9 |
206 (
color & 0x0000F800) >> 6 |
207 (
color & 0x000000F8) >> 3);
214 return (
u16)((
color & 0x80000000) >> 16|
215 (
color & 0x00F80000) >> 9 |
216 (
color & 0x0000F800) >> 6 |
217 (
color & 0x000000F8) >> 3);
224 return (
u16)((
color & 0x00F80000) >> 8 |
225 (
color & 0x0000FC00) >> 5 |
226 (
color & 0x000000F8) >> 3);
234 return ( (( -( (
s32)
color & 0x00008000 ) >> (
s32) 31 ) & 0xFF000000 ) |
235 ((
color & 0x00007C00 ) << 9) | ((
color & 0x00007000 ) << 4) |
236 ((
color & 0x000003E0 ) << 6) | ((
color & 0x00000380 ) << 1) |
237 ((
color & 0x0000001F ) << 3) | ((
color & 0x0000001C ) >> 2)
246 ((
color & 0xF800) << 8)|
247 ((
color & 0x07E0) << 5)|
248 ((
color & 0x001F) << 3);
255 return 0x8000 | (((
color & 0xFFC0) >> 1) | (
color & 0x1F));
262 return (((
color & 0x7FE0) << 1) | (
color & 0x1F));
280 return ((
color >> 10)&0x1F);
288 return ((
color >> 5)&0x1F);
296 return (
color & 0x1F);
327 :
color(((
a & 0xff)<<24) | ((
r & 0xff)<<16) | ((
g & 0xff)<<8) | (
b & 0xff)) {}
424 color = (((
a & 0xff)<<24) | ((
r & 0xff)<<16) | ((
g & 0xff)<<8) | (
b & 0xff));
458 const f32 inv = 1.0f - d;
473 const f32 inv = 1.f - d;
474 const f32 mul0 = inv * inv;
475 const f32 mul1 = 2.f * d * inv;
476 const f32 mul2 = d * d;
598 const f32 inv = 1.0f / 255.0f;
599 r =
c.getRed() * inv;
600 g =
c.getGreen() * inv;
601 b =
c.getBlue() * inv;
602 a =
c.getAlpha() * inv;
638 const f32 inv = 1.0f - d;
640 other.
g*inv +
g*d, other.
b*inv +
b*d, other.
a*inv +
a*d);
652 const f32 inv = 1.f - d;
653 const f32 mul0 = inv * inv;
654 const f32 mul1 = 2.f * d * inv;
655 const f32 mul2 = d * d;
657 return SColorf (
r * mul0 + c1.
r * mul1 + c2.
r * mul2,
658 g * mul0 + c1.
g * mul1 + c2.
g * mul2,
659 b * mul0 + c1.
b * mul1 + c2.
b * mul2,
660 a * mul0 + c1.
a * mul1 + c2.
a * mul2);
737 const f32 delta = maxVal-minVal;
781 const f32 rm1 = 2.0f * l - rm2;
784 color.set( toRGB1(rm1, rm2,
h + 1.
f/3.
f),
786 toRGB1(rm1, rm2,
h - 1.
f/3.
f)
792 inline f32 SColorHSL::toRGB1(
f32 rm1,
f32 rm2,
f32 rh)
const 800 rm1 = rm1 + (rm2 - rm1) * rh*6.
f;
803 else if (rh < 2.
f/3.
f)
804 rm1 = rm1 + (rm2 - rm1) * ((2.
f/3.
f)-rh)*6.
f;
signed short s16
16 bit signed variable.
f32 getAlpha() const
Returns the alpha component of the color in the range 0.0 (transparent) to 1.0 (opaque)
u16 RGB16(u32 r, u32 g, u32 b)
Creates a 16 bit A1R5G5B5 color.
REALINLINE s32 round32(f32 x)
void setBlue(u32 b)
Sets the blue component of the Color.
u32 getAlpha() const
Returns the alpha component of the color.
bool iszero(const f64 a, const f64 tolerance=ROUNDING_ERROR_f64)
returns if a equals zero, taking rounding errors into account
void set(f32 rr, f32 gg, f32 bb)
Sets three color components to new values at once.
GLuint GLfloat GLfloat GLfloat x1
16 bit format using 16 bits for depth.
f32 g
green color component
64 bit format using 32 bits for the red and green channels.
SColor getInterpolated(const SColor &other, f32 d) const
Interpolates the color with a f32 value to another color.
SColor operator+(const SColor &other) const
Adds two colors, result is clamped to 0..255 values.
GLdouble GLdouble GLdouble r
float f32
32 bit floating point variable.
const c8 *const ColorFormatNames[ECF_UNKNOWN+2]
Names for ECOLOR_FORMAT types.
u32 getGreen() const
Returns the green component of the color.
void setRed(u32 r)
Sets the red component of the Color.
64 bit format using 16 bits for the red, green, blue and alpha channels.
32 bit format using 32 bits for the red channel.
GLfloat GLfloat GLfloat GLfloat h
char c8
8 bit character variable.
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
void toRGB(SColorf &color) const
ECOLOR_FORMAT
An enum for the color format of textures used by the Irrlicht Engine.
u16 RGBA16(u32 r, u32 g, u32 b, u32 a=0xFF)
Creates a 16 bit A1R5G5B5 color.
f32 getLightness() const
Get lightness of the color in the range [0,255].
void set(u32 a, u32 r, u32 g, u32 b)
Sets all four components of the color at once.
Everything in the Irrlicht Engine can be found in this namespace.
u32 A1R5G5B5toA8R8G8B8(u16 color)
Convert A8R8G8B8 Color from A1R5G5B5 color.
16 bit format using 16 bits for the red channel.
32 bit format using 24 bits for depth and 8 bits for stencil.
void toOpenGLColor(u8 *dest) const
Converts color to OpenGL color format.
u16 RGB16from16(u16 r, u16 g, u16 b)
Creates a 16bit A1R5G5B5 color, based on 16bit input values.
void setAlpha(u32 a)
Sets the alpha component of the Color.
SColorHSL(f32 h=0.f, f32 s=0.f, f32 l=0.f)
unsigned char u8
8 bit unsigned variable.
SColorf getInterpolated_quadratic(const SColorf &c1, const SColorf &c2, f32 d) const
Returns interpolated color. ( quadratic )
unsigned short u16
16 bit unsigned variable.
void setData(const void *data, ECOLOR_FORMAT format)
set the color by expecting data in the given format
f32 a
alpha color component
SColor()
Constructor of the Color. Does nothing.
bool equals(const T a, const T b, const T tolerance=roundingError< T >())
returns if a equals b, taking possible rounding errors into account
void setColorComponentValue(s32 index, f32 value)
Sets a color component by index. R=0, G=1, B=2, A=3.
bool operator<(const SColor &other) const
comparison operator
signed int s32
32 bit signed variable.
u16 R5G6B5toA1R5G5B5(u16 color)
Returns A1R5G5B5 Color from R5G6B5 color.
f32 getBlue() const
Returns the blue component of the color in the range 0.0 to 1.0.
f32 getRed() const
Returns the red component of the color in the range 0.0 to 1.0.
u32 getAlpha(u16 color)
Returns the alpha component from A1R5G5B5 color.
GLsizei const GLfloat * value
128 bit format using 32 bits for the red, green, blue and alpha channels.
unsigned int u32
32 bit unsigned variable.
16 bit color format used by the software driver.
8 bit format using 8 bits for the red channel.
SColor toSColor() const
Converts this color to a SColor without floats.
u16 A1R5G5B5toR5G6B5(u16 color)
Returns R5G6B5 Color from A1R5G5B5 color.
const T & min_(const T &a, const T &b)
returns minimum of two values. Own implementation to get rid of the STL (VS6 problems)
SColor(u32 a, u32 r, u32 g, u32 b)
Constructs the color from 4 values representing the alpha, red, green and blue component.
void setGreen(u32 g)
Sets the green component of the Color.
void set(f32 aa, f32 rr, f32 gg, f32 bb)
Sets all four color components to new values at once.
bool operator==(const SColor &other) const
Compares the color to another color.
const T & max_(const T &a, const T &b)
returns maximum of two values. Own implementation to get rid of the STL (VS6 problems)
bool operator!=(const SColor &other) const
Compares the color to another color.
s32 getAverage(s16 color)
Returns the average from a 16 bit A1R5G5B5 color.
u16 toA1R5G5B5() const
Calculates a 16 bit A1R5G5B5 value of this color.
u16 X8R8G8B8toA1R5G5B5(u32 color)
Converts a 32bit (X8R8G8B8) color to a 16bit A1R5G5B5 color.
16 bit format using 16 bits for the red channel.
Class representing a 32 bit ARGB color.
32 bit format using 16 bits for the red and green channels.
void getData(void *data, ECOLOR_FORMAT format) const
Write the color to data in the defined format.
f32 getLuminance() const
Get luminance of the color in the range [0,255].
u32 getGreen(u16 color)
Returns the green component from A1R5G5B5 color.
GLboolean GLboolean GLboolean b
u16 A8R8G8B8toR5G6B5(u32 color)
Converts a 32bit (A8R8G8B8) color to a 16bit R5G6B5 color.
Standard 16 bit color format.
u32 getBlue(u16 color)
Returns the blue component from A1R5G5B5 color.
u16 A8R8G8B8toA1R5G5B5(u32 color)
Converts a 32bit (A8R8G8B8) color to a 16bit A1R5G5B5 color.
SColorf()
Default constructor for SColorf.
f32 getGreen() const
Returns the green component of the color in the range 0.0 to 1.0.
SColorf(SColor c)
Constructs a color from 32 bit Color.
SColorf(f32 r, f32 g, f32 b, f32 a=1.0f)
Constructs a color from up to four color values: red, green, blue, and alpha.
GLboolean GLboolean GLboolean GLboolean a
32 bit format using 32 bits for depth.
REALINLINE s32 floor32(f32 x)
SColorf getInterpolated(const SColorf &other, f32 d) const
Interpolates the color with a f32 value to another color.
u32 getRed(u16 color)
Returns the red component from A1R5G5B5 color.
Class representing a color in HSL format.
SColor(u32 clr)
Constructs the color from a 32 bit value. Could be another color.
Class representing a color with four floats.
u32 getRed() const
Returns the red component of the color.
32 bit format using 16 bits for the red and green channels.
16 bit format using 8 bits for the red and green channels.
u32 getBlue() const
Returns the blue component of the color.
u32 getAverage() const
Get average intensity of the color in the range [0,255].
const T clamp(const T &value, const T &low, const T &high)
clamps a value between low and high
u32 color
color in A8R8G8B8 Format
SColor getInterpolated_quadratic(const SColor &c1, const SColor &c2, f32 d) const
Returns interpolated color. ( quadratic )
u32 R5G6B5toA8R8G8B8(u16 color)
Returns A8R8G8B8 Color from R5G6B5 color.
void fromRGB(const SColorf &color)