Function toSRgb8Result

Checked computational-to-storage conversion with a typed public result.

ColorResult!(SRgb8,ColorStorageError) toSRgb8Result(T)(
  SRgb!T value
) pure nothrow @nogc @safe;

Example

SRgb8 packed = SRgb8(1, 2, 3);

assert(tryToSRgb8(
    SRgbd(1.0, 0.5, 0.0),
    packed
));
assert(packed == SRgb8(255, 128, 0));

const beforeFailure = packed;

assert(!tryToSRgb8(
    SRgbd(double.nan, 0.5, 0.0),
    packed
));
assert(packed == beforeFailure);