HSx

HSx color space is used to describe a suite of angular color spaces including HSL, HSV, HSI, HSY.

@safe pure nothrow @nogc
struct HSx (
HSxType type_
CT = float
RGBColorSpace colorSpace_ = RGBColorSpace.sRGB
) if (
isFloatingPoint!CT ||
isUnsigned!CT
) {}

Members

Aliases

ComponentType
alias ComponentType = CT

Type of the color components.

Functions

opCast
Color opCast()
Undocumented in source. Be warned that the author may not have intended to support it.

Manifest constants

colorSpace
enum colorSpace;

The color space specified.

type
enum type;

The color type from the HSx family.

Mixins

__anonymous
mixin ColorOperators!(Components!type)
Undocumented in source.

Examples

// HSL color with float components
alias HSLf = HSx!(HSxType.HSL, float);

HSLf c = HSLf(3.1415, 1, 0.5);

// test HSL operators and functions
static assert(HSLf(3.1415, 0.2, 0.5) + HSLf(0, 0.5, 0.5) == HSLf(3.1415, 0.7, 1));
static assert(HSLf(2, 0.5, 1) * 100.0 == HSLf(200, 50, 100));
// HSV color with float components
alias HSVf = HSx!(HSxType.HSV, float);

HSVf c = HSVf(3.1415, 1, 0.5);

// test HSV operators and functions
static assert(HSVf(3.1415, 0.2, 0.5) + HSVf(0, 0.5, 0.5) == HSVf(3.1415, 0.7, 1));
static assert(HSVf(2, 0.5, 1) * 100.0 == HSVf(200, 50, 100));
// HSI color with float components
alias HSIf = HSx!(HSxType.HSI, float);

HSIf c = HSIf(3.1415, 1, 0.5);

// test HSI operators and functions
static assert(HSIf(3.1415, 0.2, 0.5) + HSIf(0, 0.5, 0.5) == HSIf(3.1415, 0.7, 1));
static assert(HSIf(2, 0.5, 1) * 100.0 == HSIf(200, 50, 100));
// HCY color with float components
alias HCYf = HSx!(HSxType.HCY, float);

HCYf c = HCYf(3.1415, 1, 0.5);

// test HCY operators and functions
static assert(HCYf(3.1415, 0.2, 0.5) + HCYf(0, 0.5, 0.5) == HCYf(3.1415, 0.7, 1));
static assert(HCYf(2, 0.5, 1) * 100.0 == HCYf(200, 50, 100));

Meta