Class ColorVector
Version added: before 9.5
The ColorVector class is used to represent a color. The rgb_color class is also used to represent colors, but ColorVector's are useful when you need to perform mathematical operations on colors.
If necessary, instances of this class can be created by:
- Local variable:
- Global (see Script Structure about conventions for naming globals):
If necessary, instances of this class can be created by:
- Local variable:
local cv = LM.ColorVector:new_local()
- Global (see Script Structure about conventions for naming globals):
XX_cv = LM.ColorVector:new()
Methods of ColorVector:
Name | Returns | Description | Ver |
AsColorStruct AsColorStruct() | rgb_color | Converts a ColorVector into an rgb_color object, returning the new object | < 9.5 |
Invert Invert() | void | Inverts a color | < 9.5 |
IsBlack IsBlack() | bool | Returns true if a color is pure black, false otherwise | < 9.5 |
IsOpaque IsOpaque() | bool | Returns true if a color is totally opaque, false otherwise | < 9.5 |
IsTransparent IsTransparent() | bool | Returns true if a color is totally transparent, false otherwise | < 9.5 |
IsWhite IsWhite() | bool | Returns true if a color is pure white, false otherwise | < 9.5 |
Mag Mag() | real | Computes the magnitude of a color vector | < 9.5 |
Normalize Normalize() | void | Normalizes a ColorVector | < 9.5 |
operator‑ operator-(col2) | ColorVector | Subtracts one color from another and returns the result as a new color | < 9.5 |
operator* operator*(col2) | ColorVector | Multiplies one color by another and returns the result as a new color | < 9.5 |
operator* operator*(f) | ColorVector | Multiplies a color by a number, returning the result as a new color | < 9.5 |
operator+ operator+(col2) | ColorVector | Adds two colors and returns the result as a new color | < 9.5 |
operator/ operator/(f) | ColorVector | Divides a color by a number, returning the result as a new color | < 9.5 |
Set Set(cr, cg, cb) | void | Set the value of a color by r, g and b | < 9.5 |
Set Set(cr, cg, cb, ca) | void | Set the value of a color by r, g, b and a | < 9.5 |
Set Set(col) | void | Set the value of a color by copying an existing rgb_color | < 9.5 |
Set Set(col) | void | Set the value of a color by copying an existing ColorVector | < 9.5 |
SquaredMag SquaredMag() | real | Computes the squared magnitude of a color vector | < 9.5 |
Properties of ColorVector:
Name | Type | Description | Ver |
a | real | The alpha (or opacity) component of the color. Values can range from 0 to 1. An alpha of 0 is a totally transparent color, while a value of 1 indicates a totally opaque color. | < 9.5 |
b | real | The blue component of the color. Values can range from 0 to 1. | < 9.5 |
g | real | The green component of the color. Values can range from 0 to 1. | < 9.5 |
r | real | The red component of the color. Values can range from 0 to 1. | < 9.5 |