Color.this

Constructs Color from float components. If no components present color will default to white ([1, 1, 1, 1])

  1. this(float val)
  2. this(float val, float a)
  3. this(float[3] vals)
  4. this(float[4] vals)
    struct Color
    this
    (
    in float[4] vals...
    )

Examples

// You can explicitly define alpha or omit it
Color red = Color(1, 0, 0);
Color reda = Color(1, 0, 0, 1); 
// If presented with one or two components
// color will fill rgb portion of itself
// with only this component
// You can also omit/define alpha with it
Color gray = Color(0.5); 
Color graya = Color(0.5, 0.8);
// Also theres two aliases to help you
// GLSL style color as type
col c = col(0.2, 0.4, 1)
// And custom constructor that allows you
// to use 8 bit values (0-255)
Color webCol = Color8(255, 0, 255);
// Colors can be accessed with array slicing,
// by using color symbols or swizzling (rgba)
float rcomp = c.r;
float gcomp = c[1];
float bcomp = c.b;
float[] redblue = c.rb;
float[] redbluebluegreen = c.rbbg;

Meta