Color (struct)

The color type represents a 32 bit float 4 channel color value, storing the components ordered as red, green, blue and alpha.

参考

RGBA, ARGB

/*
** Example: Construct Color
*/

Color colorFromByte(255, 0, 0);
Color colorFromScalar(0.0, 1.0, 0.0);

Color blendColor = colorFromByte.linearInterpolate(colorFromScalar, 0.6);

Color Color Color

Members

Scalar r  
Scalar g  
Scalar b  
Scalar a  

Methods

  Color ( in Color other )
  Color ( in Float64 v )
  Color ( in Integer r, in Integer g, in Integer b )
  Color ( in Integer r, in Integer g, in Integer b, in Integer a )
  Color ( in RGB r )
  Color ( in RGBA r )
  Color ( in SInt16 v )
  Color ( in SInt32 v )
  Color ( in SInt64 v )
  Color ( in Scalar r, in Scalar g, in Scalar b )
  Color ( in Scalar r, in Scalar g, in Scalar b, in Scalar a )
  Color ( in Scalar v )
  Color ( in UInt16 r, in UInt16 g, in UInt16 b )
  Color ( in UInt16 r, in UInt16 g, in UInt16 b, in UInt16 a )
  Color ( in UInt16 v )
  Color ( in UInt32 v )
  Color ( in UInt64 v )
  Color ( in UInt8 r, in UInt8 g, in UInt8 b )
  Color ( in UInt8 r, in UInt8 g, in UInt8 b, in UInt8 a )
  Color ( in UInt8 v )
  Color ( in Vec3 v )
  Color ( in Vec4 v )
  Color ()
Color add ? ( in Color other )
Boolean almostEqual ? ( in Color other )
Boolean almostEqual ? ( in Color other, in Scalar precision )
Color clone ? ()
Scalar component ? ( in Size i )
Color divide ? ( in Color other )
Color divideScalar ? ( in Scalar other )
Boolean equal ? ( in Color other )
  get ? ( io Float32 v<> )
  get ? ( io Float32 v<>, in UInt32 o )
  get ? ( io Float32 v[] )
  get ? ( io Float32 v[], in UInt32 o )
  get ? ( io Float64 v<> )
  get ? ( io Float64 v<>, in UInt32 o )
  get ? ( io Float64 v[] )
  get ? ( io Float64 v[], in UInt32 o )
UInt32 hash ? ()
Color linearInterpolate ? ( in Color other, in Scalar t )
Color multiply ? ( in Color other )
Color multiplyScalar ? ( in Scalar other )
  set ! ( in Float32 v<> )
  set ! ( in Float32 v<>, in UInt32 o )
  set ! ( in Float64 v<> )
  set ! ( in Float64 v<>, in UInt32 o )
  set ! ( in Scalar r, in Scalar g, in Scalar b, in Scalar a )
  setComponent ! ( in Size i, in Scalar v )
  setFromHSV ! ( in Scalar hue, in Scalar saturation, in Scalar value )
Color subtract ? ( in Color other )
  toHSV ? ( out Scalar hue, out Scalar saturation, out Scalar value )
RGB toRGB ? ()
RGBA toRGBA ? ()

Operators

Color = ( Param other )

Methods in detail

Color ( in Color other )

copy constructor


Color ( in Float64 v )

Constructor from a single Float64 component, alpha = 1.0


Color ( in Integer r, in Integer g, in Integer b )

Constructor from rgb Integer components, alpha = 255


Color ( in Integer r, in Integer g, in Integer b, in Integer a )

Constructor from rgba Integer components


Color ( in RGB r )

Constructor from a RGB color, alpha = 255


Color ( in RGBA r )

Constructor from a RGBA color


Color ( in SInt16 v )

Constructor from a single SInt16 component, alpha = 1.0


Color ( in SInt32 v )

Constructor from a single SInt32, alpha = 1.0


Color ( in SInt64 v )

Constructor from a single SInt64, alpha = 1.0


Color ( in Scalar r, in Scalar g, in Scalar b )

Constructor from rgb Scalar components, alpha = 1.0


Color ( in Scalar r, in Scalar g, in Scalar b, in Scalar a )

Constructor from rgba Scalar components


Color ( in Scalar v )

Constructor from a single Scalar component, alpha = 1.0


Color ( in UInt16 r, in UInt16 g, in UInt16 b )

Constructor from rgb UInt16 components, alpha = 255


Color ( in UInt16 r, in UInt16 g, in UInt16 b, in UInt16 a )

Constructor from rgba UInt16 components


Color ( in UInt16 v )

Constructor from a single UInt16 component, alpha = 1.0


Color ( in UInt32 v )

Constructor from a single UInt32, alpha = 1.0


Color ( in UInt64 v )

Constructor from a single UInt64, alpha = 1.0


Color ( in UInt8 r, in UInt8 g, in UInt8 b )

Constructor from rgb UInt8 components, alpha = 255


Color ( in UInt8 r, in UInt8 g, in UInt8 b, in UInt8 a )

Constructor from rgba UInt8 components


Color ( in UInt8 v )

Constructor from a single UInt8 component, alpha = 1.0


Color ( in Vec3 v )

Constructor from a Vec3, alpha = 1.0


Color ( in Vec4 v )

Constructor from a Vec4


Color ()

Default constructor, red = 0.0, green = 0.0, blue = 0.0, alpha = 1.0


Color Color.add? ( in Color other )

Overload method for the add operator.


Boolean Color.almostEqual? ( in Color other )

Returns true if both colors match almost (using the PRECISION constant)


Boolean Color.almostEqual? ( in Color other, in Scalar precision )

Returns true if both colors match to a given precision


Color Color.clone? ()

clone method


Scalar Color.component? ( in Size i )

Returns the Color‘s component given an index (0 to 3)


Color Color.divide? ( in Color other )

Overload method for the divide operator.


Color Color.divideScalar? ( in Scalar other )

Overload method for the divide Scalar operator


Boolean Color.equal? ( in Color other )

Returns true if both Colors match exactly


Color.get? ( io Float32 v<> )

Getter as external float32 array


Color.get? ( io Float32 v<>, in UInt32 o )

Getter as external float32 array and an offset


Color.get? ( io Float32 v[] )

Getter as float32 array


Color.get? ( io Float32 v[], in UInt32 o )

Getter as float32 array and an offset


Color.get? ( io Float64 v<> )

Getter as external float64 array


Color.get? ( io Float64 v<>, in UInt32 o )

Getter as external float64 array and an offset


Color.get? ( io Float64 v[] )

Getter as float64 array


Color.get? ( io Float64 v[], in UInt32 o )

Getter as external float64 array and an offset


UInt32 Color.hash? ()

Hash for this value


Color Color.linearInterpolate? ( in Color other, in Scalar t )

Linearly interpolates this Color with another one based on the blend value t (0.0 to 1.0)


Color Color.multiply? ( in Color other )

Overload method for the multiply operator.


Color Color.multiplyScalar? ( in Scalar other )

Overload method for the multiply Scalar operator


Color.set! ( in Float32 v<> )

Setter from (standard/external) float32 array


Color.set! ( in Float32 v<>, in UInt32 o )

Setter from (standard/external) float32 array and an offset


Color.set! ( in Float64 v<> )

Setter from (standard/external) float64 array


Color.set! ( in Float64 v<>, in UInt32 o )

Setter from (standard/external) float64 array and an offset


Color.set! ( in Scalar r, in Scalar g, in Scalar b, in Scalar a )

Setter using rgba Scalar components


Color.setComponent! ( in Size i, in Scalar v )

Sets the Color‘s component given an index (0 to 3)


Color.setFromHSV! ( in Scalar hue, in Scalar saturation, in Scalar value )

Converts HSV to color representation (hue is in radians).


Color Color.subtract? ( in Color other )

Overload method for the subtract operator.


Color.toHSV? ( out Scalar hue, out Scalar saturation, out Scalar value )

Converts a color to HSV representation (hue is in radians). When unknown (white, gray, black), ‘s’ and ‘v’ will be 0 (some implementation return NAN).


RGB Color.toRGB? ()

Returns this Color as a RGB byte color.


RGBA Color.toRGBA? ()

Returns this Color as a RGBA byte color.

Operators in detail

Color = ( Param other )

Add-assign operator, adds another Color to this one