Clutter.Color

Fields

Name

Type

Access

Description

alpha

int

r/w

alpha component, between 0 and 255

blue

int

r/w

blue component, between 0 and 255

green

int

r/w

green component, between 0 and 255

red

int

r/w

red component, between 0 and 255

Methods

class

alloc ()

class

from_hls (hue, luminance, saturation)

class

from_pixel (pixel)

class

from_string (str)

class

get_static (color)

class

new (red, green, blue, alpha)

add (b)

copy ()

darken ()

equal (v2)

free ()

hash ()

init (red, green, blue, alpha)

interpolate (final, progress)

lighten ()

shade (factor)

subtract (b)

to_hls ()

to_pixel ()

to_string ()

Details

class Clutter.Color

Color representation.

classmethod alloc()
Returns:

the newly allocated Clutter.Color; use Clutter.Color.free() to free its resources

Return type:

Clutter.Color

Allocates a new, transparent black Clutter.Color.

New in version 1.12.

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

  • luminance (float) – luminance value, in the 0 .. 1 range

  • saturation (float) – saturation value, in the 0 .. 1 range

Returns:

return location for a Clutter.Color

Return type:

color: Clutter.Color

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

classmethod from_pixel(pixel)
Parameters:

pixel (int) – a 32 bit packed integer containing a color

Returns:

return location for a Clutter.Color

Return type:

color: Clutter.Color

Converts pixel from the packed representation of a four 8 bit channel color to a Clutter.Color.

classmethod from_string(str)
Parameters:

str (str) – a string specifiying a color

Returns:

True if parsing succeeded, and False otherwise

color:

return location for a Clutter.Color

Return type:

(bool, color: Clutter.Color)

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

The color is not allocated.

The format of str can be either one of:

  • a standard name (as taken from the X11 rgb.txt file)

  • 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.

New in version 1.0.

classmethod get_static(color)
Parameters:

color (Clutter.StaticColor) – the named global color

Returns:

a pointer to a static color; the returned pointer is owned by Clutter and it should never be modified or freed

Return type:

Clutter.Color

Retrieves a static color for the given color name

Static colors are created by Clutter and are guaranteed to always be available and valid

New in version 1.6.

classmethod new(red, green, blue, alpha)
Parameters:
  • red (int) – red component of the color, between 0 and 255

  • green (int) – green component of the color, between 0 and 255

  • blue (int) – blue component of the color, between 0 and 255

  • alpha (int) – alpha component of the color, between 0 and 255

Returns:

the newly allocated color. Use Clutter.Color.free() when done

Return type:

Clutter.Color

Creates a new Clutter.Color with the given values.

This function is the equivalent of:

clutter_color_init (clutter_color_alloc (), red, green, blue, alpha);

New in version 0.8.

add(b)
Parameters:

b (Clutter.Color) – a Clutter.Color

Returns:

return location for the result

Return type:

result: Clutter.Color

Adds self to b and saves the resulting color inside result.

The alpha channel of result is set as as the maximum value between the alpha channels of self and b.

copy()
Returns:

an allocated copy of self.

Return type:

Clutter.Color

Makes a copy of the color structure. The result must be freed using Clutter.Color.free().

New in version 0.2.

darken()
Returns:

return location for the darker color

Return type:

result: Clutter.Color

Darkens self by a fixed amount, and saves the changed color in result.

equal(v2)
Parameters:

v2 (Clutter.Color) – a Clutter.Color

Returns:

True if the two colors are the same.

Return type:

bool

Compares two Clutter.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 Clutter.Color s as keys in a GLib.HashTable.

New in version 0.2.

free()

Frees a color structure created with Clutter.Color.copy().

New in version 0.2.

hash()
Returns:

a hash value corresponding to the color

Return type:

int

Converts a Clutter.Color to a hash value.

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

New in version 1.0.

init(red, green, blue, alpha)
Parameters:
  • red (int) – red component of the color, between 0 and 255

  • green (int) – green component of the color, between 0 and 255

  • blue (int) – blue component of the color, between 0 and 255

  • alpha (int) – alpha component of the color, between 0 and 255

Returns:

the initialized Clutter.Color

Return type:

Clutter.Color

Initializes self with the given values.

New in version 1.12.

interpolate(final, progress)
Parameters:
Returns:

return location for the interpolation

Return type:

result: Clutter.Color

Interpolates between self and final Clutter.Color s using progress

New in version 1.6.

lighten()
Returns:

return location for the lighter color

Return type:

result: Clutter.Color

Lightens self by a fixed amount, and saves the changed color in result.

shade(factor)
Parameters:

factor (float) – the shade factor to apply

Returns:

return location for the shaded color

Return type:

result: Clutter.Color

Shades self by factor and saves the modified color into result.

subtract(b)
Parameters:

b (Clutter.Color) – a Clutter.Color

Returns:

return location for the result

Return type:

result: Clutter.Color

Subtracts b from self and saves the resulting color inside result.

This function assumes that the components of self are greater than the components of b; the result is, otherwise, undefined.

The alpha channel of result is set as the minimum value between the alpha channels of self and b.

to_hls()
Returns:

hue:

return location for the hue value or None

luminance:

return location for the luminance value or None

saturation:

return location for the saturation value or None

Return type:

(hue: float, luminance: float, saturation: 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.

to_pixel()
Returns:

a packed color

Return type:

int

Converts self into a packed 32 bit integer, containing all the four 8 bit channels used by Clutter.Color.

to_string()
Returns:

a newly-allocated text string

Return type:

str

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

New in version 0.2.