v_sim.Shade

Fields

None

Methods

class

getById (id)

class

getStorage ()

class

new (labelUTF8, vectA, vectB, colorMode)

class

newFromData (labelUTF8, len, vectCh1, vectCh2, vectCh3, colorMode)

class

newFromSteps (labelUTF8, lst, colorMode)

class

newFromString (labelUTF8, descr, colorMode)

channelToRGB (rgba, values)

compare (sh2)

copy ()

free ()

getColorMode ()

getLabel ()

getLinearCoeff (vectA, vectB)

getMode ()

setColorMode (mode)

setLinearCoeff (coeff, channel, order)

valueToRGB (rgba, value)

Details

class v_sim.Shade

Short name to address _ToolShade objects.

classmethod getById(id)
Parameters:

id (int) – an id.

Returns:

a v_sim.Shade from the pool.

Return type:

v_sim.Shade

Convenience function calling v_sim.Pool.getById() on the default v_sim.Shade storage.

New in version 3.8.

classmethod getStorage()
Returns:

a pointer to the internal shade list.

Return type:

v_sim.Pool

It returns a read-only pointer to the internal shade list. Use tool_shade_appendList() to add new shades to this list.

New in version 3.8.

classmethod new(labelUTF8, vectA, vectB, colorMode)
Parameters:
  • labelUTF8 (str) – a UTF8 string that shortly named this new shade ;

  • vectA (float) – an array of three floating point values ;

  • vectB (float) – an array of three floating point values ;

  • colorMode (v_sim.ShadeColorMode) – an integer that describes the color code (see v_sim.ShadeColorMode enumeration).

Returns:

the newly created v_sim.Shade.

Return type:

v_sim.Shade

Create a linear shade. Its profile is given by an AX+B formula, dealing on three channels. These channels are defined by the colorMode parameter. All given values are copied when the new shade is created.

classmethod newFromData(labelUTF8, len, vectCh1, vectCh2, vectCh3, colorMode)
Parameters:
  • labelUTF8 (str) – a UTF8 string that shortly named this new shade ;

  • len (int) – the size of arguments vectCh1, vectCh2 and vectCh3 ;

  • vectCh1 (float) – an array of floating point values for the first channel ;

  • vectCh2 (float) – an array of floating point values for the second channel ;

  • vectCh3 (float) – an array of floating point values for the third channel ;

  • colorMode (v_sim.ShadeColorMode) – an integer that describes the color code (see v_sim.ShadeColorMode enumeration).

Returns:

the newly created v_sim.Shade.

Return type:

v_sim.Shade

Create a v_sim.Shade from direct data for three channels. These channels are defined by the colorMode parameter. All given values are copied when the new shade is created.

classmethod newFromSteps(labelUTF8, lst, colorMode)
Parameters:
Returns:

the newly created v_sim.Shade.

Return type:

v_sim.Shade

Create a v_sim.Shade from a set of steps defining colours at given indexes. These channels are defined by the colorMode parameter. All given values are copied when the new shade is created. The values of indexes will be normalised by this call to range in [0;1]. Colour channel values must be in [0;1] for each step.

New in version 3.7.

classmethod newFromString(labelUTF8, descr, colorMode)
Parameters:
Raises:

GLib.Error

Returns:

the newly created v_sim.Shade.

Return type:

v_sim.Shade

As v_sim.Shade.newFromSteps() routine, but it takes an unparsed string describing the steps in descr.

New in version 3.7.

channelToRGB(rgba, values)
Parameters:
  • rgba (float) – a location to store the result of the colour transformation ;

  • values (float) – inout values.

Like v_sim.Shade.valueToRGB() but here, the three values are applied respectivly for the Red, the Green and the Blue channel.

compare(sh2)
Parameters:

sh2 (v_sim.Shade) – a v_sim.Shade.

Returns:

True if shade1 is equivalent to shade2.

Return type:

bool

Compare if the two shade are identical (first, smae mode, then same values).

copy()
Returns:

a newly created shade.

Return type:

v_sim.Shade

Create a new shade deep copy of the first.

free()

Free all dynamic memory from self and free self itself.

getColorMode()
Returns:

the color mode.

Return type:

v_sim.ShadeColorMode

Get the color mode of the shade (RGB or HSV).

getLabel()
Returns:

a string naming the shade.

Return type:

str

Get the name (in UTF8) of the shade.

getLinearCoeff(vectA, vectB)
Parameters:
  • vectA (float) – a pointer to a floating point values array to store vect in AX+B ;

  • vectB (float) – a pointer to a floating point values array to store vect in AX+B.

Returns:

True if vectA, vectB and vectX have been set correctly.

Return type:

bool

This methods can get the linear color transformation. The given arrays (vectA, vectB) are read-only. This method return False if the self is not in a v_sim.ShadeMode.LINEAR state.

getMode()
Returns:

the mode.

Return type:

v_sim.ShadeMode

Get the mode of the shade (linear, array…).

setColorMode(mode)
Parameters:

mode (v_sim.ShadeColorMode) – a new mode for the shade.

Returns:

True if mode is different from previous self mode.

Return type:

bool

Change the mode of the shade, see v_sim.ShadeColorMode.

setLinearCoeff(coeff, channel, order)
Parameters:
  • coeff (float) – a new value ;

  • channel (int) – either RGBA (from 0 to 3) ;

  • order (int) – the order in the linear approx (0 means constant and 1 is the linear coeeficient).

Returns:

True if the new value changes anything.

Return type:

bool

Change one value coeff of the linear mode for the given self.

valueToRGB(rgba, value)
Parameters:
  • rgba (float) – an array of size [4] ;

  • value (float) – the value ranged in [0;1].

Give a RGBA vector for the given value.