v_sim.Color¶
Fields¶
Name |
Type |
Access |
Description |
|---|---|---|---|
repr |
[ |
r/w |
store the representation of the colour as “#rrggbbaa”. |
rgba |
[ |
r/w |
the coding of color in Red, Green, Blue, Alpha format, floating point numbers between 0 and 1 ; |
userData |
r/w |
unused. |
Methods¶
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
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 andv_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.Coloror 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.Coloror the already existing one.- Return type:
This method adds a new color in the list of stored colors with the given values.
- classmethod convertHSLtoRGB(rgb, hsl)¶
- Parameters:
This methods convert a HSL color to a RGB one.
- classmethod convertHSVtoRGB(rgb, hsv)¶
- Parameters:
This methods convert a HSV color to a RGB one.
- classmethod convertRGBtoHSL(hsl, rgb)¶
- Parameters:
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, seev_sim.Color.getStorage().New in version 3.8.
- classmethod getByValues(red, green, blue, alpha)¶
- Parameters:
- Returns:
the found color, or
Noneif 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.Poolobject.- Return type:
Give access to the
v_sim.Poolinstance storing all the colors.New in version 3.8.
- classmethod invertRGBA(inv, rgba)¶
- Parameters:
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(useGLib.free() to free it).- Return type:
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 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:
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) – av_sim.Colorto read the values from.
This method copies all values from color_old to self.
- equal(color2)¶
- Parameters:
color2 (
v_sim.Color) – an otherv_sim.Color.- Returns:
Trueif the rgba attributes are the same.- Return type:
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:
This method is used by
v_sim.UiColorComboboxobject to create little stamps representing the color. If the pixbuf of such stamps are needed, usev_sim.UiColorCombobox.getPixbufFromColor() if the color is registered in an already existingv_sim.UiColorComboboxobject or use this method to create a new stamp.New in version 3.7.