v_sim.Color

Fields

Name

Type

Access

Description

repr

[int]

r/w

store the representation of the colour as “#rrggbbaa”.

rgba

[float]

r/w

the coding of color in Red, Green, Blue, Alpha format, floating point numbers between 0 and 1 ;

userData

object

r/w

unused.

Methods

class

addFloatRGBA (rgba)

class

addIntRGBA (rgba)

class

convertHSLtoRGB (rgb, hsl)

class

convertHSVtoRGB (rgb, hsv)

class

convertRGBtoHSL (hsl, rgb)

class

fromName (name)

class

fromStr (str)

class

getByValues (red, green, blue, alpha)

class

getStorage ()

class

invertRGBA (inv, rgba)

class

new (rgba)

class

new_bright (id)

asStr ()

copy (color_old)

equal (color2)

get_stamp (alpha)

Details

class v_sim.Color

A structure to store colors. repr is not set before v_sim.Color.asStr() is called. Any changes in rgba are not transfered to repr and v_sim.Color.asStr() should be called again.

classmethod addFloatRGBA(rgba)
Parameters:

rgba (float) – four values between 0. and 1. that represent [Red, Green, Blue, Alpha] ;

Returns:

a newly created v_sim.Color or the already existing one.

position:

an int pointer to store the position of the returned colour.

Return type:

(v_sim.Color, position: int)

This method adds a new color in the list of stored colors with the given values. If it already exits it returns the pointer of that color.

classmethod addIntRGBA(rgba)
Parameters:

rgba (int) – four values between 0 and 255 that represent [Red, Green, Blue, Alpha].

Returns:

a newly created v_sim.Color or the already existing one.

Return type:

v_sim.Color

This method adds a new color in the list of stored colors with the given values.

classmethod convertHSLtoRGB(rgb, hsl)
Parameters:
  • rgb (float) – an allocated 3 elements array to receive the RGB values ;

  • hsl (float) – a 3 elements array to retrieve the HSL values from.

This methods convert a HSL color to a RGB one.

classmethod convertHSVtoRGB(rgb, hsv)
Parameters:
  • rgb (float) – an allocated 3 elements array to receive the RGB values ;

  • hsv (float) – a 3 elements array to retrieve the HSV values from.

This methods convert a HSV color to a RGB one.

classmethod convertRGBtoHSL(hsl, rgb)
Parameters:
  • hsl (float) – three float to store the HSL value ;

  • rgb (float) – three floats giving the RGB values.

Convert a RGB colour into a HSL one.

classmethod fromName(name)
Parameters:

name (str) – a string.

Returns:

a corresponding v_sim.Color, creating it if necessary.

pos:

a location.

Return type:

(v_sim.Color, pos: int)

Parse a name like ‘black’ and generate a colour. This color is added to the pool, see v_sim.Color.getStorage().

New in version 3.8.

classmethod fromStr(str)
Parameters:

str (str) – a string.

Returns:

a corresponding v_sim.Color, creating it if necessary.

pos:

a location.

Return type:

(v_sim.Color, pos: int)

This method parse str with the format %RRGGBB or %RRGGBBAA to create a v_sim.Color. This color is added to the pool, see v_sim.Color.getStorage().

New in version 3.8.

classmethod getByValues(red, green, blue, alpha)
Parameters:
  • red (float) – a value between 0. and 1. ;

  • green (float) – a value between 0. and 1. ;

  • blue (float) – a value between 0. and 1. ;

  • alpha (float) – a value between 0. and 1..

Returns:

the found color, or None if none exists.

pos:

an allocated int to store the position of the found color ;

Return type:

(v_sim.Color, pos: int)

This method is used to look for a specific color in the stored list. The argument pos is -1 if nothing is found or stores the position (beginning at 0) of the found color.

classmethod getStorage()
Returns:

a v_sim.Pool object.

Return type:

v_sim.Pool

Give access to the v_sim.Pool instance storing all the colors.

New in version 3.8.

classmethod invertRGBA(inv, rgba)
Parameters:
  • inv (float) – a location to store the inverted colour.

  • rgba (float) – a colour defined in RGBA.

Invert the colour on the stack.

New in version 3.8.

classmethod new(rgba)
Parameters:

rgba ([float]) –

four values between 0. and

that represent [Red, Green, Blue, Alpha].

Returns:

a new allocated v_sim.Color (use GLib.free() to free it).

Return type:

v_sim.Color

Create a new color with initial values given as arguments.

classmethod new_bright(id)
Parameters:

id (int) – an index

Returns:

a bright color.

Return type:

v_sim.Color

V_Sim has a list of 20 bright colors. One can get one by calling this routine. The id is taken modulo the number of available colors.

New in version 3.7.

asStr()
Returns:

a string representing self.

Return type:

str

Gives a string representation of self. The string is computed at each call.

New in version 3.8.

copy(color_old)
Parameters:

color_old (v_sim.Color) – a v_sim.Color to read the values from.

This method copies all values from color_old to self.

equal(color2)
Parameters:

color2 (v_sim.Color) – an other v_sim.Color.

Returns:

True if the rgba attributes are the same.

Return type:

bool

Test if the two colours are the same.

get_stamp(alpha)
Parameters:

alpha (bool) – a boolean.

Returns:

a pixbuf pointer corresponding to the little image as shown on a colorComboBox (use GObject.Object.unref() to free this pixbuf).

Return type:

GdkPixbuf.Pixbuf

This method is used by v_sim.UiColorCombobox object to create little stamps representing the color. If the pixbuf of such stamps are needed, use v_sim.UiColorCombobox.getPixbufFromColor() if the color is registered in an already existing v_sim.UiColorCombobox object or use this method to create a new stamp.

New in version 3.7.