These functions are declared in the following header file. Link with allegro_color.

 #include <allegro5/allegro_color.h>

al_color_cmyk

ALLEGRO_COLOR al_color_cmyk(float c, float m, float y, float k)

Source Code

Return an ALLEGRO_COLOR structure from CMYK values (cyan, magenta, yellow, black).

See also: al_color_cmyk_to_rgb, al_color_rgb_to_cmyk

al_color_cmyk_to_rgb

void al_color_cmyk_to_rgb(float cyan, float magenta, float yellow,
    float key, float *red, float *green, float *blue)

Source Code

Convert CMYK values to RGB values.

See also: al_color_cmyk, al_color_rgb_to_cmyk

al_color_hsl

ALLEGRO_COLOR al_color_hsl(float h, float s, float l)

Source Code

Return an ALLEGRO_COLOR structure from HSL (hue, saturation, lightness) values.

Parameters:

See also: al_color_hsl_to_rgb, al_color_hsv

al_color_hsl_to_rgb

void al_color_hsl_to_rgb(float hue, float saturation, float lightness,
   float *red, float *green, float *blue)

Source Code

Convert values in HSL color model to RGB color model.

Parameters:

See also: al_color_rgb_to_hsl, al_color_hsl, al_color_hsv_to_rgb

al_color_hsv

ALLEGRO_COLOR al_color_hsv(float h, float s, float v)

Source Code

Return an ALLEGRO_COLOR structure from HSV (hue, saturation, value) values.

Parameters:

See also: al_color_hsv_to_rgb, al_color_hsl

al_color_hsv_to_rgb

void al_color_hsv_to_rgb(float hue, float saturation, float value,
   float *red, float *green, float *blue)

Source Code

Convert values in HSV color model to RGB color model.

Parameters:

See also: al_color_rgb_to_hsv, al_color_hsv, al_color_hsl_to_rgb

al_color_html

ALLEGRO_COLOR al_color_html(char const *string)

Source Code

Interprets an HTML-style hex number (e.g. #00faff) as a color. The accepted format is the same as al_color_html_to_rgb.

Returns the interpreted color, or al_map_rgba(0, 0, 0, 0) if the string could not be parsed.

Note: the behaviour on invalid strings is different from Allegro 5.0.x.

See also: al_color_html_to_rgb, al_color_rgb_to_html

al_color_html_to_rgb

bool al_color_html_to_rgb(char const *string,
   float *red, float *green, float *blue)

Source Code

Interprets an HTML-style hex number (e.g. #00faff) as a color. The only accepted formats are "#RRGGBB" and "RRGGBB" where R, G, B are hexadecimal digits [0-9A-Fa-f].

Returns true on success, false on failure. On failure all components are set to zero.

Note: the behaviour on invalid strings is different from Allegro 5.0.x.

See also: al_color_html, al_color_rgb_to_html

al_color_rgb_to_html

void al_color_rgb_to_html(float red, float green, float blue,
    char *string)

Source Code

Create an HTML-style string representation of an ALLEGRO_COLOR, e.g. #00faff.

Parameters:

Example:

char html[8];
al_color_rgb_to_html(1, 0, 0, html);

Now html will contain "#ff0000".

See also: al_color_html, al_color_html_to_rgb

al_color_name

ALLEGRO_COLOR al_color_name(char const *name)

Source Code

Return an ALLEGRO_COLOR with the given name. If the color is not found then black is returned.

See al_color_name_to_rgb for the list of names.

al_color_name_to_rgb

bool al_color_name_to_rgb(char const *name, float *r, float *g, float *b)

Source Code

Parameters:

The recognized names are:

aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, goldenrod, gold, gray, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavenderblush, lavender, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgreen, lightgrey, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, avajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, purwablue, red, rosybrown, royalblue, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen

They are taken from http://www.w3.org/TR/2010/PR-css3-color-20101028/#svg-color.

Returns: true if a name from the list above was passed, else false.

See also: al_color_name

al_color_rgb_to_cmyk

void al_color_rgb_to_cmyk(float red, float green, float blue,
   float *cyan, float *magenta, float *yellow, float *key)

Source Code

Each RGB color can be represented in CMYK with a K component of 0 with the following formula:

C = 1 - R
M = 1 - G
Y = 1 - B
K = 0

This function will instead find the representation with the maximal value for K and minimal color components.

See also: al_color_cmyk, al_color_cmyk_to_rgb

al_color_rgb_to_hsl

void al_color_rgb_to_hsl(float red, float green, float blue,
   float *hue, float *saturation, float *lightness)

Source Code

Given an RGB triplet with components in the range 0..1, return the hue in degrees from 0..360 and saturation and lightness in the range 0..1.

See also: al_color_hsl_to_rgb, al_color_hsl

al_color_rgb_to_hsv

void al_color_rgb_to_hsv(float red, float green, float blue,
   float *hue, float *saturation, float *value)

Source Code

Given an RGB triplet with components in the range 0..1, return the hue in degrees from 0..360 and saturation and value in the range 0..1.

See also: al_color_hsv_to_rgb, al_color_hsv

al_color_rgb_to_name

char const *al_color_rgb_to_name(float r, float g, float b)

Source Code

Given an RGB triplet with components in the range 0..1, find a color name describing it approximately.

See also: al_color_name_to_rgb, al_color_name

al_color_rgb_to_yuv

void al_color_rgb_to_yuv(float red, float green, float blue,
   float *y, float *u, float *v)

Source Code

Convert RGB values to YUV color space.

See also: al_color_yuv, al_color_yuv_to_rgb

al_color_yuv

ALLEGRO_COLOR al_color_yuv(float y, float u, float v)

Source Code

Return an ALLEGRO_COLOR structure from YUV values.

See also: al_color_yuv_to_rgb, al_color_rgb_to_yuv

al_color_yuv_to_rgb

void al_color_yuv_to_rgb(float y, float u, float v,
    float *red, float *green, float *blue)

Source Code

Convert YUV color values to RGB color space.

See also: al_color_yuv, al_color_rgb_to_yuv

al_get_allegro_color_version

uint32_t al_get_allegro_color_version(void)

Source Code

Returns the (compiled) version of the addon, in the same format as al_get_allegro_version.

Allegro version 5.2.2 - Last updated: 2016-12-13 05:25:46 UTC