Color

Color structure with data accesible with [N] or swizzling

Constructors

this
this(float val)
this(float val, float a)
this(float[3] vals)
this(float[4] vals)

Constructs Color from float components. If no components present color will default to white ([1, 1, 1, 1])

Alias This

data

Alias to allow easy data access

Members

Aliases

arrayof
alias arrayof = data

Alias to data

Functions

a8
ubyte a8()
b8
ubyte b8()

Returns color component in 8 bit form

clamp
void clamp(float min, float max)

Clamps color values between min and max

copyof
Color copyof()

Returns copy of color

darken
void darken(float p_amount)

Darkens color by p_amount

g8
ubyte g8()

Returns color component in 8 bit form

hue
float hue()

Returns h component of hsv

invert
void invert()

Inverts color

lerp
void lerp(Color p_to, float p_weight)

Returns the linear interpolation with another color

lighten
void lighten(float p_amount)

Lightens color by p_amount

luminance
float luminance()

Returns the luminance of the color in the [0.0, 1.0] range

opBinary
auto opBinary(Color!(R, N) b)
auto opBinary(R b)
opBinaryRight
auto opBinaryRight(Color!(R, N) b)
auto opBinaryRight(R b)

opBinary x [+, -, *, /, %] y

opCast
R opCast()
bool opCast()

opCast cast(x) y

opCmp
int opCmp(Color!(R, N) b)

opCmp x [< > <= >=] y

opEquals
bool opEquals(Color!(R, 4) b)

opEquals x == y

opOpAssign
auto opOpAssign(Color!(R, N) b)
auto opOpAssign(R b)

opOpAssign x [+, -, *, /, %]= y

opUnary
auto opUnary()

opUnary [-, +, --, ++] x

ptr
float* ptr()

Returns pointer to data

r8
ubyte r8()

Returns color component in 8 bit form

saturation
float saturation()

Returns s component of hsv

setAnsi
void setAnsi(int ansi)

Sets color from ANSI256 index

setAnsi8
void setAnsi8(int ansi)

Sets color from ANSI index

setHex
void setHex(uint p_hex, bool p_hasAlpha)

Sets color to hexadecimal value

setHsv
void setHsv(float p_h, float p_s, float p_v, float p_alpha)

Sets color from hsv

setHtml
void setHtml(string html)

Sets color from html string in format #RRGGBB

toAnsi
int toAnsi()

Returns closest ANSI256 color index

toAnsi8
int toAnsi8(bool isBackground)

Returns closest ANSI8 color index

toAnsi8String
string toAnsi8String(bool isBackground)

Returns closest bash ANSI8 color string

toAnsiString
string toAnsiString(bool isBackground)

Returns closest bash ANSI256 color string

toHash
size_t toHash()

Returns hash

toHex
uint toHex()

Returns hex representation of color in format 0xrrggbb

toHtml
string toHtml(bool p_alpha)

Returns html representation of color in format #RRGGBB If p_alpha is true returns color in format #RRGGBBAA

toString
string toString()

Returns string representation of color: [1.00, 1.00, 1.00, 1.00]

toTrueColorString
string toTrueColorString(bool isBackground)

Returns bash truecolor string

value
float value()

Returns v component of hsv

Manifest constants

AccessString
enum AccessString;
Undocumented in source.

Mixins

__anonymous
mixin accessByString!(float, 4, "data", AccessString)
Undocumented in source.

Variables

data
float[4] data;

Color data

Mixed In Members

From mixin accessByString!(float, 4, "data", AccessString)

opDispatch
T opDispatch [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
opDispatch
T opDispatch [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
opDispatch
auto opDispatch [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
opDispatch
U opDispatch [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.

Meta