blueprints.thing.colored module#

blueprints.thing.colored.gradient(*colors, n_steps)[source]#

This function creates a color gradient in form of a list of colors, which are interpolated between argument color.

>>> blue.gradient('red', 'yellow', n_steps=6)
[Red[#FF0000], Red[#F52900], Orange[#EB5200], Orange[#E07A00], Yellow[#D6A300], Yellow[#CCCC00]]
Parameters:
  • colors (list) – A list of colors given in any of the formats specified by Color.

  • n_steps (int) – The number of steps taken from the first to the last color.

Returns:

List of colors interpolated in n_steps along all given colors.

Return type:

list

class blueprints.thing.colored.Color[source]#

Bases: ColorType

The color descriptor can be one of the following:

  • string containing the colors name: 'orange'

  • string containing the colors hex code as RGB: '#FFFF00'

  • string containing the colors hex code as RGBA: '#FFFF0080'

  • integer specifying the colors hex code as RGB 0xFFFF00

  • list containing the colors components as RGB: [1, 1, 0]

  • list containing the colors components as RGBA: [1, 1, 0, 0.5]

  • np.array containing the colors components as RGB: [1, 1, 0]

  • np.array containing the colors components as RGBA: [1, 1, 0, 0.5]

  • Color object.

__init__(descriptor, opacity=None)[source]#
Parameters:
  • descriptor (str | int | list[int | float] | ndarray | ColorType)

  • opacity (int | float | None)

property name: str#

The name is set to be the closest name among default colors.

Return type:

str

property rgb: ndarray#

The values are synchronized with rgba, red,:attr:green and blue .

Returns:

The color array without opacity.

Return type:

np.ndarray

property rgba: ndarray#

The values are synchronized with rgb, red,:attr:green, blue and opacity.

Returns:

The color array with opacity.

Return type:

np.ndarray

property red: float | None#

The value is synchronized with rgb and rgba.

Returns:

The red component of the color array.

Return type:

float | None

property green: float | None#

The value is synchronized with rgb and rgba.

Returns:

The green component of the color array.

Return type:

float | None

property blue: float | None#

The value is synchronized with rgb and rgba.

Returns:

The blue component of the color array.

Return type:

float | None

property opacity: int | float#

The value is synchronized with rgba.

Returns:

The opacity component of the color array.

Return type:

int | float

class blueprints.thing.colored.ColoredThing[source]#

Bases: ColoredThingType, BaseThing

This class is used to implement color. The color components are stored in the rgba property. Those components are also accessible as individual properties red, green, blue and opacity. All components of the color array must be in the range [0, 1].

Note

The transparency of ColoredThing is modified via opacity, and not with alpha, since this property is reserved for blueprints.thing.moveable.MoveableThing.alpha!

Parameters:
  • rgb (list[int | float] | np.ndarray | None, optional) – The color array without opacity.

  • rgba (list[int | float] | np.ndarray | None, optional) – The color array with opacity.

  • **kwargs – Keyward arguments are passed to super().__init__.

__init__(color='white', opacity=None, **kwargs)[source]#
Parameters:
  • rgb (list[int | float] | np.ndarray | None, optional) – The color array without opacity.

  • rgba (list[int | float] | np.ndarray | None, optional) – The color array with opacity.

  • **kwargs – Keyward arguments are passed to super().__init__.

property color: ColorType#

The Color contains all attributes of the ColoredThing color components.

Return type:

Color

property rgb: ndarray#

The values are synchronized with rgba, red,:attr:green and blue .

Returns:

The color array without opacity.

Return type:

np.ndarray

property rgba: ndarray | None#

The values are synchronized with rgb, red,:attr:green, blue and opacity.

Returns:

The color array with opacity.

Return type:

np.ndarray

property red: float | None#

The value is synchronized with rgb and rgba.

Returns:

The red component of the color array.

Return type:

float | None

property green: float | None#

The value is synchronized with rgb and rgba.

Returns:

The green component of the color array.

Return type:

float | None

property blue: float | None#

The value is synchronized with rgb and rgba.

Returns:

The blue component of the color array.

Return type:

float | None

property opacity: int | float#

The value is synchronized with rgba.

Returns:

The opacity component of the color array.

Return type:

int | float