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:
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 rgb_color Converts a ColorVector into an rgb_color object, returning the new object < 9.5
Invert void Inverts a color < 9.5
IsBlack bool Returns true if a color is pure black, false otherwise < 9.5
IsOpaque bool Returns true if a color is totally opaque, false otherwise < 9.5
IsTransparent bool Returns true if a color is totally transparent, false otherwise < 9.5
IsWhite bool Returns true if a color is pure white, false otherwise < 9.5
Mag real Computes the magnitude of a color vector < 9.5
Normalize void Normalizes a ColorVector < 9.5
operator* ColorVector Multiplies a color by a number, returning the result as a new color < 9.5
operator* ColorVector Multiplies one color by another and returns the result as a new color < 9.5
operator/ ColorVector Divides a color by a number, returning the result as a new color < 9.5
operator‑ ColorVector Subtracts one color from another and returns the result as a new color < 9.5
operator+ ColorVector Adds two colors and returns the result as a new color < 9.5
Set void Set the value of a color by copying an existing LM_ColorVector < 9.5
Set void Set the value of a color by copying an existing rgb_color < 9.5
Set void Set the value of a color by r, g and b < 9.5
Set void Set the value of a color by r, g, b and a < 9.5
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