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 byColor.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:
ColorTypeThe 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
0xFFFF00list 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 andblue.- Returns:
The color array without opacity.
- Return type:
np.ndarray
- property rgba: ndarray#
The values are synchronized with
rgb,red,:attr:green,blueandopacity.- Returns:
The color array with opacity.
- Return type:
np.ndarray
- property red: float | None#
The value is synchronized with
rgbandrgba.- Returns:
The red component of the color array.
- Return type:
float | None
- property green: float | None#
The value is synchronized with
rgbandrgba.- Returns:
The green component of the color array.
- Return type:
float | None
- class blueprints.thing.colored.ColoredThing[source]#
Bases:
ColoredThingType,BaseThingThis class is used to implement color. The color components are stored in the
rgbaproperty. Those components are also accessible as individual propertiesred,green,blueandopacity. All components of the color array must be in the range [0, 1].Note
The transparency of
ColoredThingis modified viaopacity, and not withalpha, since this property is reserved forblueprints.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
Colorcontains all attributes of theColoredThingcolor components.- Return type:
- property rgb: ndarray#
The values are synchronized with
rgba,red,:attr:green andblue.- Returns:
The color array without opacity.
- Return type:
np.ndarray
- property rgba: ndarray | None#
The values are synchronized with
rgb,red,:attr:green,blueandopacity.- Returns:
The color array with opacity.
- Return type:
np.ndarray
- property red: float | None#
The value is synchronized with
rgbandrgba.- Returns:
The red component of the color array.
- Return type:
float | None
- property green: float | None#
The value is synchronized with
rgbandrgba.- Returns:
The green component of the color array.
- Return type:
float | None