Skip to content

Color ​

A 32-bit RGBA color value.

Static Methods ​

from_gradient ​

navi
from_gradient(
    value: float,
    bottom_value: float,
    top_value: float,
    bottom_color: Color,
    top_color: Color
  ): Color

Creates a color that is a gradient between bottom_color and top_color based on the value between bottom_value and top_value.

Parameters

NameTypeDefaultDescription
valuefloatThe value to use for interpolation (between bottom_value and top_value).
bottom_valuefloatThe lower bound of the value range.
top_valuefloatThe upper bound of the value range.
bottom_colorColorThe color to use when value equals bottom_value.
top_colorColorThe color to use when value equals top_value.

Returns: Color

See Also: Color.new, Color.rgb, Color.mix


mix ​

navi
mix(c1: Color, c2: Color, weight: float = 0.5): Color

Linearly blends two colors.

Parameters

NameTypeDefaultDescription
c1ColorThe first color.
c2ColorThe second color.
weightfloat0.5Blend weight in [0.0, 1.0]. 0.0 = full c1, 1.0 = full c2.

Returns: Color

See Also: Color.from_gradient


new ​

navi
new(color: Color, transp: float): Color

Creates a new color by changing the transparency of the given color to transp (0-100).

Parameters

NameTypeDefaultDescription
colorColorThe color to modify.
transpfloatThe new transparency value (0-100).

Returns: Color

See Also: Color.rgb, Color.from_gradient


rgb ​

navi
rgb(red: float, green: float, blue: float, transp: float = 0): Color

Creates a color from the specified red, green, blue components (0-255) and optional transparency (0-100).

Parameters

NameTypeDefaultDescription
redfloatThe red component value (0-255).
greenfloatThe green component value (0-255).
bluefloatThe blue component value (0-255).
transpfloat0The transparency value (0-100, default: 0.0).

Returns: Color

See Also: Color.new, Color.from_gradient

Static Properties ​

AQUA ​

Type: const Color

Color constant for #00BCD4.


BLACK ​

Type: const Color

Color constant for #363A45.


BLUE ​

Type: const Color

Color constant for #2962FF.


BROWN ​

Type: const Color

Color constant for #795548.


CORAL ​

Type: const Color

Color constant for #FF7043.


CYAN ​

Type: const Color

Color constant for #00BFF3.


FUCHSIA ​

Type: const Color

Color constant for #E040FB.


GOLD ​

Type: const Color

Color constant for #FFD700.


GRAY ​

Type: const Color

Color constant for #787B86.


GREEN ​

Type: const Color

Color constant for #4CAF50.


INDIGO ​

Type: const Color

Color constant for #3F51B5.


LIME ​

Type: const Color

Color constant for #00E676.


MAROON ​

Type: const Color

Color constant for #880E4F.


Type: const Color

Color constant for #311B92.


OLIVE ​

Type: const Color

Color constant for #808000.


ORANGE ​

Type: const Color

Color constant for #FF9800.


PINK ​

Type: const Color

Color constant for #E91E63.


PURPLE ​

Type: const Color

Color constant for #9C27B0.


RED ​

Type: const Color

Color constant for #F23645.


SILVER ​

Type: const Color

Color constant for #B2B5BE.


TEAL ​

Type: const Color

Color constant for #089981.


VIOLET ​

Type: const Color

Color constant for #7B1FA2.


WHITE ​

Type: const Color

Color constant for #FFFFFF.


YELLOW ​

Type: const Color

Color constant for #FDD835.

Methods ​

alpha ​

navi
alpha(self: Color): float

Returns the transparency component of the given color.

Parameters

NameTypeDefaultDescription
selfColor

Returns: float — A value in the range [0, 100] where 0 is fully opaque and 100 is fully transparent.

See Also: Color.red, Color.green, Color.blue


blue ​

navi
blue(self: Color): float

Returns the blue component of the given color.

Parameters

NameTypeDefaultDescription
selfColor

Returns: float — A value in the range [0, 255].

See Also: Color.red, Color.green, Color.alpha


green ​

navi
green(self: Color): float

Returns the green component of the given color.

Parameters

NameTypeDefaultDescription
selfColor

Returns: float — A value in the range [0, 255].

See Also: Color.red, Color.blue, Color.alpha


red ​

navi
red(self: Color): float

Returns the red component of the given color.

Parameters

NameTypeDefaultDescription
selfColor

Returns: float — A value in the range [0, 255].

See Also: Color.green, Color.blue, Color.alpha