color

Color representation and Algan’s named color palette.

Algan stores color in five channels – red, green, blue, glow, alpha – so that emissive strength travels with a color the way opacity does. RGB and alpha are in [0, 1]; glow is an additive brightness fed to the bloom accumulator.

Color accepts the forms you would expect – a hex string such as "#58C4DD", or an (r, g, b) tuple – with glow and opacity as separate arguments. It subclasses torch.Tensor, so a color takes part in ordinary tensor arithmetic and can carry batch dimensions. Color.add_defaults() pads a bare RGB or RGBA tensor out to the five-channel layout, which is how the API accepts the shorter forms wherever a color array is expected.

The module then defines the palette exported by from algan import *: BLACK, WHITE, the greys, and the BLUE/RED/GREEN/YELLOW families with their _A (lightest) through _E (darkest) shades. Both British and American spellings of grey are provided. Two special values are worth knowing: TRANSPARENT (invisible, and the background color that produces an alpha-channel video) and GLOW (black with full glow).

Classes

Color

A color, as five channels: red, green, blue, glow and opacity.

Functions

color_to_texture_map(color)[source]
to_color(value)[source]

Coerce a user-supplied color into something Algan can store.

The colors Algan hands out are Color constants, but the ones users reach for first are the ones every other graphics library takes: a hex string, a CSS name, a hex int, an RGB triple. Materials have accepted all of those since they were written – MeshStandardMaterial(color= 0x8B5A2B) is how the shipped presets are spelled – while Square( color="#ff0000") raised AttributeError: 'str' object has no attribute 'reshape' from deep inside the timeline. This is the one place that decides, so both spellings mean the same thing.

Anything already tensor-shaped is returned untouched: a per-row color buffer is a legitimate value and must not be collapsed to one color.

Parameters:

value – A Color, a hex string ("#ff0000") or CSS name ("red"), a hex int (0xff0000), an RGB/RGBA/RGBA+glow sequence of floats in [0, 1], a tensor, or None.

Return type:

Color or the value unchanged

Raises:

InvalidColorError – If value is a string that names no color, or a bool.