| Guifications Library Reference Manual |
|---|
GfColormapGfColormap — GfColor API |
GfColor;
GfColor* gf_color_copy (const GfColor *color);
gboolean gf_color_from_rgb (GfColor *color,
guint16 red,
guint16 green,
guint16 blue);
gboolean gf_color_to_rgb (const GfColor *color,
guint16 *red,
guint16 *green,
guint16 *blue);
gboolean gf_color_from_hsv (GfColor *color,
guint16 hue,
guint16 saturation,
guint16 value);
gboolean gf_color_to_hsv (const GfColor *color,
guint16 *hue,
guint16 *saturation,
guint16 *value);
gboolean gf_color_from_html (GfColor *color,
const gchar *html);
gchar* gf_color_to_html (const GfColor *color);
GfColormap;
gboolean gf_colormap_alloc_color (GfColormap *colormap,
GfColor *color,
gboolean writable,
gboolean best_match);
gint gf_colormap_alloc_colors (GfColormap *colormap,
GfColor *colors,
gint ncolors,
gboolean writable,
gboolean best_match,
gboolean *success);
void gf_colormap_free_colors (GfColormap *colormap,
GfColor *colors,
gint ncolors);
void gf_colormap_query_color (GfColormap *colormap,
gulong pixel,
GfColor *result);
To handle colors in a user interface abstracted way, we have an abstract base class of GfColormap. Each user interface has to implement the a specific colormap for that user interface.
typedef struct {
guint32 pixel;
guint16 red;
guint16 green;
guint16 blue;
} GfColor;
GfColor is a structure used to define a color.
guint32 pixel; |
For allocated colors, the value used to draw this color on the screen. |
guint16 red; |
The red value, 0-65535. |
guint16 green; |
The green value, 0-65535. |
guint16 blue; |
The blue value, 0-65535. |
GfColor* gf_color_copy (const GfColor *color);
Creates a copy of color.
color : |
The GfColor to copy. |
| Returns : | A copy of color.
|
gboolean gf_color_from_rgb (GfColor *color, guint16 red, guint16 green, guint16 blue);
Initializes color from red, green, and blue.
color : |
The GfColor. |
red : |
The red value. |
green : |
The green value. |
blue : |
The blue value. |
| Returns : | TRUE if initialization was successful. |
gboolean gf_color_to_rgb (const GfColor *color, guint16 *red, guint16 *green, guint16 *blue);
Gets red, green, and blue from color.
color : |
The GfColor. |
red : |
The return address for the red value. |
green : |
The return address for the green value. |
blue : |
The return address for the blue value. |
| Returns : | TRUE if successful. |
gboolean gf_color_from_hsv (GfColor *color, guint16 hue, guint16 saturation, guint16 value);
Initializes color from hue, saturation, and value values.
color : |
The GfColor. |
hue : |
The hue value. |
saturation : |
The saturation value. |
value : |
The value value. |
| Returns : | TRUE if successful. |
gboolean gf_color_to_hsv (const GfColor *color, guint16 *hue, guint16 *saturation, guint16 *value);
Gets hue, saturation, and value from color.
color : |
The GfColor. |
hue : |
The return address for the hue value. |
saturation : |
The return address for the saturation value. |
value : |
The return address for the value value. |
| Returns : | TRUE if successful. |
gboolean gf_color_from_html (GfColor *color, const gchar *html);
Initializes color from html.
color : |
The GfColor. |
html : |
The HTML color value. |
| Returns : | TRUE if successful. |
gchar* gf_color_to_html (const GfColor *color);
Gets the HTML color value for color.
color : |
The GfColor. |
| Returns : | The HTML color value for color, or NULL. If not NULL, this
value must be freed using g_free().
|
typedef struct _GfColormap GfColormap;
GfColormap is an opaque structure that should not be used directly.
gboolean gf_colormap_alloc_color (GfColormap *colormap, GfColor *color, gboolean writable, gboolean best_match);
Allocates color for colormap.
colormap : |
The GfColormap instance. |
color : |
The GfColor instance. |
writable : |
Whether or not color can be changed.
|
best_match : |
Whether or not to match against existing colors. |
| Returns : | TRUE on success. |
gint gf_colormap_alloc_colors (GfColormap *colormap, GfColor *colors, gint ncolors, gboolean writable, gboolean best_match, gboolean *success);
Allocates an array of colors for colormap.
colormap : |
The GfColormap instance. |
colors : |
An array of GfColor's. |
ncolors : |
The number of colors.
|
writable : |
Whether or not colors can be changed.
|
best_match : |
Whethor or not to match against existing colors. |
success : |
An array of length ncolors, which represents if the
corresponding color was successfully allocated.
|
| Returns : | The number of colors that were not successfully allocated.
|
void gf_colormap_free_colors (GfColormap *colormap, GfColor *colors, gint ncolors);
Frees allocated colors.
colormap : |
The GfColormap instance. |
colors : |
The GfColor's to free. |
ncolors : |
The number of colors.
|
void gf_colormap_query_color (GfColormap *colormap, gulong pixel, GfColor *result);
Locates the RGB color in colormap coresponding to pixel.
colormap : |
The GfColormap instance. |
pixel : |
The pixel value. |
result : |
The GfColor that's been allocated to pixel.
|
| << GfDrawable | GfGC >> |