Class (GI Struct)

Cogl-18CoglColor

A generic color definition

Cogl.Color is a simple structure holding the definition of a color such that it can be efficiently used by GL

Index

Constructors

  • Parameters

    • Optionalproperties: Partial<{ alpha: number; blue: number; green: number; red: number }>

    Returns Cogl.Color

Properties

alpha: number
blue: number
green: number
red: number
$gtype: GType<Cogl.Color>

Methods

  • Frees the resources allocated by cogl_color_new() and cogl_color_copy()

    Returns void

  • Retrieves the alpha channel of color as a fixed point value between 0 and 1.0.

    Returns number

    the alpha channel of the passed color

  • Retrieves the blue channel of color as a fixed point value between 0 and 1.0.

    Returns number

    the blue channel of the passed color

  • Retrieves the green channel of color as a fixed point value between 0 and 1.0.

    Returns number

    the green channel of the passed color

  • Retrieves the red channel of color as a fixed point value between 0 and 1.0.

    Returns number

    the red channel of the passed color

  • Sets the values of the passed channels into a Cogl.Color

    Parameters

    • red: number

      value of the red channel, between 0 and 1.0

    • green: number

      value of the green channel, between 0 and 1.0

    • blue: number

      value of the blue channel, between 0 and 1.0

    • alpha: number

      value of the alpha channel, between 0 and 1.0

    Returns void

  • Converts a non-premultiplied color to a pre-multiplied color. For example, semi-transparent red is (1.0, 0, 0, 0.5) when non-premultiplied and (0.5, 0, 0, 0.5) when premultiplied.

    Returns void

  • Converts color to the HLS format.

    The hue value is in the 0 .. 360 range. The luminance and saturation values are in the 0 .. 1 range.

    Returns [number, number, number]

  • Returns a textual specification of color in the hexadecimal form &num;rrggbbaa, where r, g, b and a are hexadecimal digits representing the red, green, blue and alpha components respectively.

    Returns string

    a newly-allocated text string

  • Parses a string definition of a color, filling the Cogl.Color.red, Cogl.Color.green, Cogl.Color.blue and Cogl.Color.alpha fields of color.

    The color is not allocated.

    The format of str can be either one of:

    • an hexadecimal value in the form: #rgb, #rrggbb, #rgba, or #rrggbbaa
    • a RGB color in the form: rgb(r, g, b)
    • a RGB color in the form: rgba(r, g, b, a)
    • a HSL color in the form: hsl(h, s, l) -a HSL color in the form: hsla(h, s, l, a)

    where 'r', 'g', 'b' and 'a' are (respectively) the red, green, blue color intensities and the opacity. The 'h', 's' and 'l' are (respectively) the hue, saturation and luminance values.

    In the rgb() and rgba() formats, the 'r', 'g', and 'b' values are either integers between 0 and 255, or percentage values in the range between 0% and 100%; the percentages require the '%' character. The 'a' value, if specified, can only be a floating point value between 0.0 and 1.0.

    In the hls() and hlsa() formats, the 'h' value (hue) is an angle between 0 and 360.0 degrees; the 'l' and 's' values (luminance and saturation) are percentage values in the range between 0% and 100%. The 'a' value, if specified, can only be a floating point value between 0.0 and 1.0.

    Whitespace inside the definitions is ignored; no leading whitespace is allowed.

    If the alpha component is not specified then it is assumed to be set to be fully opaque.

    Parameters

    • str: string

      a string specifying a color

    Returns [boolean, Cogl.Color]

  • Converts a color expressed in HLS (hue, luminance and saturation) values into a Cogl.Color.

    Parameters

    • hue: number

      hue value, in the 0 .. 360 range

    • saturation: number

      saturation value, in the 0 .. 1 range

    • luminance: number

      luminance value, in the 0 .. 1 range

    Returns Cogl.Color