Structure for working with colors. This structure is defined in #include <mgl2/type.h>
.
There are two ways to set the color in MathGL. First one is using of mreal values of red, green and blue channels for precise color definition. The second way is the using of character id. There are a set of characters specifying frequently used colors. Normally capital letter gives more dark color than lowercase one. See Стиль линий.
mglColor
: mreal
r, g, b, a ¶Reg, green and blue component of color.
mglColor
:
mglColor (mreal
R, mreal
G, mreal
B, mreal
A=1
)
¶Constructor sets the color by mreal values of Red, Green, Blue and Alpha channels. These values should be in interval [0,1].
mglColor
:
mglColor (char
c='k'
, mreal
bright=1
)
¶Constructor sets the color from character id. The black color is used by default. Parameter br set additional “lightness” of color.
mglColor
: void
Set (mreal
R, mreal
G, mreal
B, mreal
A=1
)
¶Sets color from values of Red, Green, Blue and Alpha channels. These values should be in interval [0,1].
mglColor
: void
Set (mglColor
c, mreal
bright=1
)
¶Sets color as “lighted” version of color c.
mglColor
: void
Set (char
p, mreal
bright=1
)
¶Sets color from symbolic id.
mglColor
: bool
Valid ()
¶Checks correctness of the color.
mglColor
: mreal
Norm ()
¶Gets maximal of spectral component.
mglColor
: bool
operator== (const mglColor &
c)
¶mglColor
: bool
operator!= (const mglColor &
c)
¶Compare with another color
mglColor
: bool
operator*= (mreal
v)
¶Multiplies color components by number v.
mglColor
: bool
operator+= (const mglColor &
c)
¶Adds color c component by component.
mglColor
: bool
operator-= (const mglColor &
c)
¶Subtracts color c component by component.
mglColor
operator+ (const mglColor &
a, const mglColor &
b)
¶Adds colors by its RGB values.
mglColor
operator- (const mglColor &
a, const mglColor &
b)
¶Subtracts colors by its RGB values.
mglColor
operator* (const mglColor &
a, mreal
b)
¶mglColor
operator* (mreal
a, const mglColor &
b)
¶Multiplies color by number.
mglColor
operator/ (const mglColor &
a, mreal
b)
¶Divide color by number.
mglColor
operator! (const mglColor &
a)
¶Return inverted color.