Agar Logo

Agar 1.7 Manual

(Printable Version)
M_Color(3)

SYNOPSIS

#include <agar/core.h>
#include <agar/gui.h>
#include <agar/math/m.h>

DESCRIPTION

The M_Color structure describes a color in terms of RGB values and an alpha component. It is defined as:
#ifdef HAVE_SSE
typedef union m_color {
	__m128 m128;
	struct { float r, g, b, a; };
} M_Color;
#else
typedef struct m_color {
	M_Real r, g, b, a;
} M_Color;
#endif

Notice that SIMD extensions force single-precision floats, regardless of the precision for which Agar-Math was built.

INITIALIZATION


M_Color M_ColorRGB (M_Real r, M_Real g, M_Real b)

M_Color M_ColorRGBA (M_Real r, M_Real g, M_Real b, M_Real a)

M_Color M_ColorHSV (M_Real hue, M_Real saturation, M_Real value)

M_Color M_ColorHSVA (M_Real hue, M_Real saturation, M_Real value, M_Real a)

M_Color M_ColorBlack (void)

M_Color M_ColorWhite (void)

M_Color M_ColorGray (M_Real c)

M_Color M_ReadColor (AG_DataSource *ds)

void M_WriteColor (AG_DataSource *ds, const M_Color *C)

void M_ColorTo4fv (const M_Color *C, float *fv)

void M_ColorTo4dv (const M_Color *C, double *fv)


The M_ColorRGB() function returns an M_Color structure describing an opaque color composed of the given red, green and blue components. The components are real values ranging from 0.0 to 1.0. M_ColorRGBA() accepts an alpha component as well.

The M_ColorHSV() and M_ColorHSVA() functions return a color specified in terms of hue, saturation and value, all real numbers ranging from 0.0 to 1.0.

M_ColorBlack() returns an opaque black and M_ColorWhite() returns an opaque white. M_ColorGray() returns a shade of gray where c ranges from 0 to 1.0.

The M_ReadColor() and M_WriteColor() functions read or write a color structure from/to an AG_DataSource(3).

M_ColorTo4fv() and M_ColorTo4dv() convert a M_Color structure to an array of 4 float or double, respectively.

SEE ALSO


HISTORY

The M_Color structure first appeared in Agar 1.3.4.

Csoft.net ElectronTubeStore