|
yage.core.color
Authors:
Eric Poggel
License:
LGPL v3
- struct
Color
;
- A struct used to represent a color.
Colors are represented in RGBA format.
Note that uints and dwords store the bytes in reverse (little endian),
so
Color
(0x6633ff00).hex == "00FF3366"
All Colors default to transparent black.
TODO:
Convert to using four floats for better arithmetic, or just make it templated?
Example:
uint red = Color("red").ui;
Vec4f blue = Color("0000FF").vec4f;
writefln(Color("blue")); // outputs "0000FF00"
writefln(Color(0x00FF0000)); // outputs "0000FF00"
- ubyte
r
;
- Access each color component: TODO: test to ensure order is correct.
- ubyte
g
;
- Access each color component: TODO: test to ensure order is correct.
- ubyte
b
;
- Access each color component: TODO: test to ensure order is correct.
- ubyte
a
;
- Access each color component: TODO: test to ensure order is correct.
- ubyte[4u]
ub
;
- Get the Color as an array of ubyte
- uint
ui
;
- Get the Color as a uint
- static Color
opCall
(int r, int g, int b, int a = 255);
static Color
opCall
(float r, float g, float b, float a = cast(float)1);
static Color
opCall
(ubyte[] v);
static Color
opCall
(int[] v);
static Color
opCall
(float[] f);
static Color
opCall
(Vec3f v);
static Color
opCall
(Vec!(4,float) v);
- Initialize from 3 or 4 values (red, green, blue, alpha).
Integer types rante from 0 to 255 and floating point types range from 0 to 1.
- static Color
opCall
(uint ui);
- Initialize from a uint, string hexadecimal value, or english color name.
Strings. can be a 6 or 8 digit hexadecimal or an English color name.
Black, blue, brown, cyan, gold, gray/grey, green, indigo, magenta, orange,
pink, purple, red, transparent, violet, white, and yellow are supported.
See:
CSS color names
- Color
opAssign
(char[] string);
Color
opAssign
(uint value);
- Assign from a uint, string hexadecimal value, or english color name.
Strings. can be a 6 or 8 digit hexadecimal or an English color name.
Black, blue, brown, cyan, gold, gray/grey, green, indigo, magenta, orange,
pink, purple, red, transparent, violet, white, and yellow are supported.
See:
CSS color names
- uint
opCast
();
- Allow casting color to a uint.
- float[]
f
();
void
f
(float[4u] result);
- Get the Color as an array of float.
- Vec3f
vec3f
();
Vec!(4,float)
vec4f
();
- Get the Color as a Vector
- char[]
hex
(bool lower = false, char[] lookaside = null);
char[]
toString
();
- Get the color as a string.
Params:
bool lower |
return lower case hexadecimal digits |
|
|