Cogl.Color

Fields

Name Type Access Description
private_member_alpha int r  
private_member_blue int r  
private_member_green int r  
private_member_padding0 int r  
private_member_padding1 int r  
private_member_padding2 int r  
private_member_red int r  

Methods

class equal (v1, v2)
class init_from_hsl (hue, saturation, luminance)
class new ()
  copy ()
  free ()
  get_alpha ()
  get_alpha_byte ()
  get_alpha_float ()
  get_blue ()
  get_blue_byte ()
  get_blue_float ()
  get_green ()
  get_green_byte ()
  get_green_float ()
  get_red ()
  get_red_byte ()
  get_red_float ()
  init_from_4f (red, green, blue, alpha)
  init_from_4fv (color_array)
  init_from_4ub (red, green, blue, alpha)
  premultiply ()
  set_alpha (alpha)
  set_alpha_byte (alpha)
  set_alpha_float (alpha)
  set_blue (blue)
  set_blue_byte (blue)
  set_blue_float (blue)
  set_from_4f (red, green, blue, alpha)
  set_from_4ub (red, green, blue, alpha)
  set_green (green)
  set_green_byte (green)
  set_green_float (green)
  set_red (red)
  set_red_byte (red)
  set_red_float (red)
  to_hsl ()
  unpremultiply ()

Details

class Cogl.Color

A structure for holding a color definition. The contents of the Cogl.Color structure are private and should never by accessed directly.

New in version 1.0.

classmethod equal(v1, v2)
Parameters:
Returns:

True if the two colors are the same.

Return type:

int

Compares two Cogl.Color s and checks if they are the same.

This function can be passed to g_hash_table_new() as the key_equal_func parameter, when using Cogl.Color s as keys in a GLib.HashTable.

New in version 1.0.

classmethod init_from_hsl(hue, saturation, luminance)
Parameters:
  • hue (float) – hue value, in the 0 .. 360 range
  • saturation (float) – saturation value, in the 0 .. 1 range
  • luminance (float) – luminance value, in the 0 .. 1 range
Returns:

return location for a Cogl.Color

Return type:

color: Cogl.Color

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

New in version 1.16.

classmethod new()
Returns:a newly-allocated Cogl.Color. Use Cogl.Color.free() to free the allocated resources
Return type:Cogl.Color

Creates a new (empty) color

New in version 1.0.

copy()
Returns:a newly-allocated Cogl.Color. Use Cogl.Color.free() to free the allocate resources
Return type:Cogl.Color

Creates a copy of self

New in version 1.0.

free()

Frees the resources allocated by Cogl.Color.new() and Cogl.Color.copy()

New in version 1.0.

get_alpha()
Returns:the alpha channel of the passed color
Return type:float

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

New in version 1.0.

get_alpha_byte()
Returns:the alpha channel of the passed color
Return type:int

Retrieves the alpha channel of self as a byte value between 0 and 255

New in version 1.0.

get_alpha_float()
Returns:the alpha channel of the passed color
Return type:float

Retrieves the alpha channel of self as a floating point value between 0.0 and 1.0

New in version 1.0.

get_blue()
Returns:the blue channel of the passed color
Return type:float

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

New in version 1.0.

get_blue_byte()
Returns:the blue channel of the passed color
Return type:int

Retrieves the blue channel of self as a byte value between 0 and 255

New in version 1.0.

get_blue_float()
Returns:the blue channel of the passed color
Return type:float

Retrieves the blue channel of self as a floating point value between 0.0 and 1.0

New in version 1.0.

get_green()
Returns:the green channel of the passed color
Return type:float

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

New in version 1.0.

get_green_byte()
Returns:the green channel of the passed color
Return type:int

Retrieves the green channel of self as a byte value between 0 and 255

New in version 1.0.

get_green_float()
Returns:the green channel of the passed color
Return type:float

Retrieves the green channel of self as a floating point value between 0.0 and 1.0

New in version 1.0.

get_red()
Returns:the red channel of the passed color
Return type:float

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

New in version 1.0.

get_red_byte()
Returns:the red channel of the passed color
Return type:int

Retrieves the red channel of self as a byte value between 0 and 255

New in version 1.0.

get_red_float()
Returns:the red channel of the passed color
Return type:float

Retrieves the red channel of self as a floating point value between 0.0 and 1.0

New in version 1.0.

init_from_4f(red, green, blue, alpha)
Parameters:
  • red (float) – value of the red channel, between 0 and 1.0
  • green (float) – value of the green channel, between 0 and 1.0
  • blue (float) – value of the blue channel, between 0 and 1.0
  • alpha (float) – value of the alpha channel, between 0 and 1.0

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

New in version 1.4.

init_from_4fv(color_array)
Parameters:color_array (float) – a pointer to an array of 4 float color components

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

New in version 1.4.

init_from_4ub(red, green, blue, alpha)
Parameters:
  • red (int) – value of the red channel, between 0 and 255
  • green (int) – value of the green channel, between 0 and 255
  • blue (int) – value of the blue channel, between 0 and 255
  • alpha (int) – value of the alpha channel, between 0 and 255

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

New in version 1.4.

premultiply()

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.

New in version 1.0.

set_alpha(alpha)
Parameters:alpha (float) – a float value between 0.0f and 1.0f

Sets the alpha channel of self to alpha.

New in version 1.4.

set_alpha_byte(alpha)
Parameters:alpha (int) – a byte value between 0 and 255

Sets the alpha channel of self to alpha.

New in version 1.4.

set_alpha_float(alpha)
Parameters:alpha (float) – a float value between 0.0f and 1.0f

Sets the alpha channel of self to alpha.

New in version 1.4.

set_blue(blue)
Parameters:blue (float) – a float value between 0.0f and 1.0f

Sets the blue channel of self to blue.

New in version 1.4.

set_blue_byte(blue)
Parameters:blue (int) – a byte value between 0 and 255

Sets the blue channel of self to blue.

New in version 1.4.

set_blue_float(blue)
Parameters:blue (float) – a float value between 0.0f and 1.0f

Sets the blue channel of self to blue.

New in version 1.4.

set_from_4f(red, green, blue, alpha)
Parameters:
  • red (float) – value of the red channel, between 0 and %1.0
  • green (float) – value of the green channel, between 0 and %1.0
  • blue (float) – value of the blue channel, between 0 and %1.0
  • alpha (float) – value of the alpha channel, between 0 and %1.0

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

New in version 1.0.

Deprecated since version 1.4: Use Cogl.Color.init_from_4f instead.

set_from_4ub(red, green, blue, alpha)
Parameters:
  • red (int) – value of the red channel, between 0 and 255
  • green (int) – value of the green channel, between 0 and 255
  • blue (int) – value of the blue channel, between 0 and 255
  • alpha (int) – value of the alpha channel, between 0 and 255

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

New in version 1.0.

Deprecated since version 1.4: Use Cogl.Color.init_from_4ub instead.

set_green(green)
Parameters:green (float) – a float value between 0.0f and 1.0f

Sets the green channel of self to green.

New in version 1.4.

set_green_byte(green)
Parameters:green (int) – a byte value between 0 and 255

Sets the green channel of self to green.

New in version 1.4.

set_green_float(green)
Parameters:green (float) – a float value between 0.0f and 1.0f

Sets the green channel of self to green.

New in version 1.4.

set_red(red)
Parameters:red (float) – a float value between 0.0f and 1.0f

Sets the red channel of self to red.

New in version 1.4.

set_red_byte(red)
Parameters:red (int) – a byte value between 0 and 255

Sets the red channel of self to red.

New in version 1.4.

set_red_float(red)
Parameters:red (float) – a float value between 0.0f and 1.0f

Sets the red channel of self to red.

New in version 1.4.

to_hsl()
Returns:
hue:return location for the hue value or None
saturation:return location for the saturation value or None
luminance:return location for the luminance value or None
Return type:(hue: float, saturation: float, luminance: float)

Converts self to the HLS format.

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

New in version 1.16.

unpremultiply()

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

New in version 1.4.