RGB.opBinary

Binary operators.

  1. typeof(this) opBinary(typeof(this) rh)
    struct RGB(string components_, ComponentType_, bool linear_ = false, RGBColorSpace colorSpace_ = RGBColorSpace.sRGB)
    @safe pure nothrow @nogc const
    typeof(this)
    opBinary
    (
    string op
    )
    (
    typeof(this) rh
    )
    if (
    op == "+" ||
    op == "-"
    ||
    op == "*"
    )
    if (
    isNumeric!ComponentType_
    )
  2. typeof(this) opBinary(S rh)

Examples

static assert(RGB8(10,20,30)       + RGB8(4,5,6) == RGB8(14,25,36));
static assert(UVW8(10,20,30)       + UVW8(4,5,6) == UVW8(14,25,36));
static assert(RGBAf32(10,20,30,40) + RGBAf32(4,5,6,7) == RGBAf32(14,25,36,47));

static assert(RGB8(10,20,30)       - RGB8(4,5,6) == RGB8(6,15,24));
static assert(UVW8(10,20,30)       - UVW8(4,5,6) == UVW8(6,15,24));
static assert(RGBAf32(10,20,30,40) - RGBAf32(4,5,6,7) == RGBAf32(6,15,24,33));

static assert(RGB8(10,20,30)       * RGB8(128,128,128) == RGB8(5,10,15));
static assert(UVW8(10,20,30)       * UVW8(-64,-64,-64) == UVW8(-5,-10,-15));
static assert(RGBAf32(10,20,30,40) * RGBAf32(0,1,2,3) == RGBAf32(0,20,60,120));

Meta