Colour
A floating-point RGBA representation of a Colour
This class does not hold any colour space information, therefore the precise meaning of the values will depend on the context in which it is used.
Categories: [‘Colour’, ‘Utility’]
Base class: _BlipValue
Properties
a : float
The alpha (transparency) component of the colour.
Between 0-1, 0 is fully transparent, 1 is fully opaque.
UserName: A
b : float
The blue component of the colour.
Between 0-1 if an sRGB value, may be outside this range otherwise.
UserName: B
g : float
The green component of the colour.
Between 0-1 if an sRGB value, may be outside this range otherwise.
UserName: G
r : float
The red component of the colour.
Between 0-1 if an sRGB value, may be outside this range otherwise.
UserName: R
Variables
black : Colour
Full black sRGB colour
blackZeroAlpha : Colour
Full black sRGB colour, with zero alpha
blue : Colour
Blue sRGB colour
caramel : Colour
Caramel sRGB colour
cyan : Colour
Cyan sRGB colour
darkGrey : Colour
Dark grey sRGB colour
green : Colour
Green sRGB colour
grey : Colour
Mid grey sRGB colour
lightGrey : Colour
Light grey sRGB colour
lime : Colour
Lime sRGB colour
magenta : Colour
Magenta sRGB colour
orange : Colour
Orange sRGB colour
pink : Colour
Pink sRGB colour
red : Colour
Red sRGB colour
transparent : Colour
Fully transparent sRGB colour
turquoise : Colour
Turquoise sRGB colour
white : Colour
Full white sRGB colour
whiteZeroAlpha : Colour
Full white sRGB colour, with zero alpha
yellow : Colour
Yellow sRGB colour
Constructors
__init__(self)
__init__(self, other: Colour)
Copy constructor for Colour
__init__(self, rgb: Colour, a: float)
__init__(self, r: float, g: float, b: float)
__init__(self, r: float, g: float, b: float, a: float)
__init__(self, col: Col)
__init__(self, hdr: HDRColour)
Methods
mix(self, c: Colour, f: float) -> Colour
Mixes two colours together.
Performs a linear interpolation between this and another colour based on a mix factor f.
Parameters:
- c: The colour to mix with.
- f: The factor of the mix, from 0-1. 0 returns this colour, 1 returns the other colour c.
Returns A new colour that is a mix between this and the given colour.
toCol(self) -> Col
Converts the colour to an 8-bit Col structure.
Returns An 8-bit Col representation of this colour.
toHSL(self) -> Vec
Convert the colour to HSL (Hue, Saturation, Luminance) format.
Returns A vector containing the hue, saturation, and luminance values of the colour.
toNormalisedColour(self) -> Colour
Converts the colour to normalised float form.
Returns A new Colour object with RGBA components limited to the range 0-1.
toVec(self) -> Vec
Converts the colour object to a vector.
Returns A vector containing the RGB components of this colour.
Static Methods
fromHSL(h: float, s: float, l: float) -> Colour
Special Methods
__add__(self, c: Colour) -> Colour
Adds two colours
Performs a component-wise addition of the two colours, including alpha. Values above one are saturated at one.
Parameters:
- c: The colour to add
Returns The resulting colour
__eq__(self, c: Colour) -> bool
Equality comparison operator for colours.
Parameters:
- c: The other colour to compare with.
Returns True if all RGBA components of the colours are equal, false otherwise.
__mul__(col, x) -> Any
Multiply the elements of the colour by a value
Parameters:
- x: A float or integer multiplier
Returns The colour with its elements multiplied by x
__ne__(self, c: Colour) -> bool
Checks if two colours are not equal.
Parameters:
- c: The other colour to compare with.
Returns True if any of the RGBA components of the colours are not equal, false otherwise.
__repr__(self) -> Any
String representation of the colour
__rmul__(col, x) -> Any
Multiply the elements of the colour by a value
Parameters:
- x: A float or integer multiplier
Returns The colour with its elements multiplied by x
__sub__(self, c: Colour) -> Colour
Subtracts another colour from this one.
Performs a component-wise subtraction of the given colour from this one. Values below zero are saturated at zero.
Parameters:
- c: The colour to subtract from this one.
Returns The resulting colour.