RGB.opBinary

Binary operators.

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

Examples

static assert(RGB8(10,20,30)       * 2 == RGB8(20,40,60));
static assert(UVW8(10,20,30)       * 2 == UVW8(20,40,60));
static assert(RGBAf32(10,20,30,40) * 2 == RGBAf32(20,40,60,80));

static assert(RGB8(10,20,30)       / 2 == RGB8(5,10,15));
static assert(UVW8(-10,-20,-30)    / 2 == UVW8(-5,-10,-15));
static assert(RGBAf32(10,20,30,40) / 2 == RGBAf32(5,10,15,20));

static assert(RGB8(10,20,30)       * 2.0 == RGB8(20,40,60));
static assert(UVW8(10,20,30)       * 2.0 == UVW8(20,40,60));
static assert(RGBAf32(10,20,30,40) * 2.0 == RGBAf32(20,40,60,80));
static assert(RGB8(10,20,30)       * 0.5 == RGB8(5,10,15));
static assert(UVW8(-10,-20,-30)    * 0.5 == UVW8(-5,-10,-15));
static assert(RGBAf32(5,10,15,20)  * 0.5 == RGBAf32(2.5,5,7.5,10));

static assert(RGB8(10,20,30)       / 2.0 == RGB8(5,10,15));
static assert(UVW8(-10,-20,-30)    / 2.0 == UVW8(-5,-10,-15));
static assert(RGBAf32(10,20,30,40) / 2.0 == RGBAf32(5,10,15,20));
static assert(RGB8(10,20,30)       / 0.5 == RGB8(20,40,60));
static assert(UVW8(10,20,30)       / 0.5 == UVW8(20,40,60));
static assert(RGBAf32(10,20,30,40) / 0.5 == RGBAf32(20,40,60,80));

Meta