pixelΒΆ

module daffodil.pixel

This module contains the implementation for the internal pixel storage mechanisms.

struct Pixel(V) if (isColorValue!V)

The storage struct for a color.

alias Value = V

The type used to store individual values for a color

Value[] values

The values of the color

ColorSpace* colorSpace

The color space used for operations with the color

this(Value[] values, const ColorSpace* colorSpace)
this(size_t size, const ColorSpace* colorSpace)
Pixel!V opBinary(string op : "*")(const real other) const
Pixel!V opBinary(string op : "+")(const Pixel!V other) const
void opOpAssign(string op : "*")(const real other)
void opOpAssign(string op : "+")(const Pixel!V other)
void opAssign(const Pixel!V other)
void clear()

Clear all the color values to 0

@property auto dup()

Return a duplicate color in the same color space

template isColorValue(V)

Template for checking whether a type is a valid color value. Color values are what daffodil stores internally.

Any floating point type, unsigned integreal or valid isCustomColorValue is a valid color value.

Examples:
assert(isColorValue!ubyte);
assert(isColorValue!uint);
assert(isColorValue!ulong);
assert(!isColorValue!int);
assert(isColorValue!float);
assert(isColorValue!real)
template isCustomColorValue(V)

Template for checking whether a type is a valid custom color value. A custom color value must have a static init property, a static fromReal that converts a real to V, and a toReal function that converts a V back to a real.

Examples:
static struct IntCV {
    int value = 0;

    static auto fromReal(real v) {
        return IntCV(cast(int)(v / int.max));
    }

    real toReal() {
        return cast(real)value / int.max;
    }
}

assert(isCustomColorValue!IntCV);
assert(isColorValue!IntCV)
V toColorValue(V)(const real value) if (isColorValue!V)

Converts a real to a specified color value.

V[] toColorValues(V)(const real[] values) if (isColorValue!V)

Converts an array of reals to an array of specified color values.

real toReal(V)(const V value) if (isColorValue!V)

Converts a valid color value to a real.

real[] toReals(V)(const V[] values) if (isColorValue!V)

Converts an array of valid color values to an array of reals.