gewel.color.ColorMap

class gewel.color.ColorMap(rgb_colors: Iterable[List[float]], position: Optional[Union[float, Tvf, PyTvf]] = None, min_position: float = 0.0, max_position: float = 1.0)[source]

Bases: gewel.color.BaseColor, gewel._timekeeper.TimekeeperMixin

A color map is a color that is derived from other colors.

Parameters
  • rgb_colors – A list of colors that make up the map.

  • position – The location in the map whose color should be returned by tuple().

Methods

fade_to_position

from_colors

is_transparent

Indicates whether the color is transparent or not, i.e. whether its alpha is certain to be zero.

ramp_attr_to

Change the value of an attribute of the object from the value it has at the current next-action time to a new value by ramping it linearly between the old and new values over the course of a given duration.

set_time

tuple

Construct a (red, green, blue, alpha) tuple representing the color.

wait

Wait for a specified amount of time.

wait_for

Wait for another object to finish whatever action it is currently doing.

wait_until

Update the next-action time so that it is at least the given time.

Attributes

position

r

time

is_transparent() bool[source]

Indicates whether the color is transparent or not, i.e. whether its alpha is certain to be zero. Checking this may be useful in checking whether something needs to be rendered or not. If the color it would be rendered is transparent then it does not.

Returns

True if the color is transparent. False otherwise.

Return type

bool

ramp_attr_to(name: str, to: float, duration: float, update_time: bool = True) None

Change the value of an attribute of the object from the value it has at the current next-action time to a new value by ramping it linearly between the old and new values over the course of a given duration.

See Next-Action Time During Scripting for more on next-action time.

Parameters
  • name – Name of the attribute to update.

  • to – Value to change to.

  • duration – Time in seconds over which the value ramps from the old to the new value.

  • update_time – If True, update the object’s next-action time so that it is duration later than it was.

tuple(t: float, alpha_multiplier: Union[float, Tvf, PyTvf] = 1.0) Tuple[float, float, float, float][source]

Construct a (red, green, blue, alpha) tuple representing the color. The red, green, and blue components are determined by the color. The alpha component may be affected by the value of the alpha_multiplier parameter.

Parameters
  • t – The time for which we want the tuple.

  • alpha_multiplier – A multiplicative factor for the alpha. The value should be between 0.0 and 1.0. It will be multiplied by the alpha of the color to produce the fourth element of the resulting tuple. Passing in 0.0 will produce alpha transparent result (alpha = 0.0) while passing in the default value of 1.0 will leave the alpha of the color unchanged.

Returns

A four element tuple, (red, green, blue, alpha) of color components for red, green, blue, and alpha (opacity). All are in the range [0.0, 1.0].

Return type

tuple

wait(duration: float) None

Wait for a specified amount of time. This updates the object’s next-action time by adding a constant amount of time to it.

See Next-Action Time During Scripting for more on next-action time.

Parameters

duration – How long to wait, in seconds.

wait_for(other: Union[gewel._timekeeper.TimekeeperMixin, Iterable[gewel._timekeeper.TimekeeperMixin]]) None

Wait for another object to finish whatever action it is currently doing. This method us used at scripting time to ensure that an object updates its next-action time so that it is no earlier than the next-action time of another object.

See Next-Action Time During Scripting for more on next-action time.

Parameters

other – The object to wait for. Or, an iterable collection of objects. If iterable, then wait for the one with the latest time.

wait_until(at_least: float) None

Update the next-action time so that it is at least the given time. If it is already greater than that, change nothing.

See Next-Action Time During Scripting for more on next-action time.

Parameters

at_least – The minimum new next-action time.