mirror of
https://github.com/brl/mutter.git
synced 2024-11-12 17:27:03 -05:00
2006-12-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-color.h: * clutter/clutter-color.c: Add clutter_color_parse(), which parses a string containing a color definition as understood by XParseColor() (or pango_color_parse()).
This commit is contained in:
parent
6d87b1479c
commit
b45b844004
@ -1,3 +1,10 @@
|
||||
2006-12-05 Emmanuele Bassi <ebassi@openedhand.com>
|
||||
|
||||
* clutter/clutter-color.h:
|
||||
* clutter/clutter-color.c: Add clutter_color_parse(),
|
||||
which parses a string containing a color definition as
|
||||
understood by XParseColor() (or pango_color_parse()).
|
||||
|
||||
2006-12-04 Emmanuele Bassi <ebassi@openedhand.com>
|
||||
|
||||
Avoid clutter segfaulting when used without invoking
|
||||
|
@ -34,7 +34,10 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "clutter-main.h"
|
||||
#include "clutter-color.h"
|
||||
#include "clutter-private.h"
|
||||
#include "clutter-debug.h"
|
||||
|
||||
/**
|
||||
* clutter_color_add:
|
||||
@ -374,6 +377,45 @@ clutter_color_from_pixel (ClutterColor *dest,
|
||||
dest->alpha = pixel % 0xff;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_color_parse:
|
||||
* @color: a string specifiying a color
|
||||
* @dest: return location for a #ClutterColor
|
||||
*
|
||||
* Parses a string definition of a color, filling the
|
||||
* <structfield>red</structfield>, <structfield>green</structfield> and
|
||||
* <structfield>blue</structfield> channels of @dest. The
|
||||
* <structfield>alpha</structfield> channel is not changed. The
|
||||
* color in @dest is not allocated.
|
||||
*
|
||||
* The color may be defined by any of the formats understood by
|
||||
* <function>XParseColor</function>; these include literal color
|
||||
* names, like <literal>Red</literal> or <literal>DarkSlateGray</literal>,
|
||||
* or hexadecimal specifications like <literal>#3050b2</literal> or
|
||||
* <literal>#333</literal>.
|
||||
*
|
||||
* Return value: %TRUE if parsing succeeded.
|
||||
*
|
||||
* Since: 0.2
|
||||
*/
|
||||
gboolean
|
||||
clutter_color_parse (const gchar *color,
|
||||
ClutterColor *dest)
|
||||
{
|
||||
PangoColor pango_color;
|
||||
|
||||
if (pango_color_parse (&pango_color, color))
|
||||
{
|
||||
dest->red = pango_color.red;
|
||||
dest->green = pango_color.green;
|
||||
dest->blue = pango_color.blue;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static ClutterColor *
|
||||
clutter_color_copy (ClutterColor *color)
|
||||
{
|
||||
|
@ -43,35 +43,37 @@ struct _ClutterColor
|
||||
guint8 alpha;
|
||||
};
|
||||
|
||||
GType clutter_color_get_type (void) G_GNUC_CONST;
|
||||
GType clutter_color_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void clutter_color_add (const ClutterColor *src1,
|
||||
const ClutterColor *src2,
|
||||
ClutterColor *dest);
|
||||
void clutter_color_subtract (const ClutterColor *src1,
|
||||
const ClutterColor *src2,
|
||||
ClutterColor *dest);
|
||||
gboolean clutter_color_parse (const gchar *color,
|
||||
ClutterColor *dest);
|
||||
void clutter_color_add (const ClutterColor *src1,
|
||||
const ClutterColor *src2,
|
||||
ClutterColor *dest);
|
||||
void clutter_color_subtract (const ClutterColor *src1,
|
||||
const ClutterColor *src2,
|
||||
ClutterColor *dest);
|
||||
|
||||
void clutter_color_lighten (const ClutterColor *src,
|
||||
ClutterColor *dest);
|
||||
void clutter_color_darken (const ClutterColor *src,
|
||||
ClutterColor *dest);
|
||||
void clutter_color_shade (const ClutterColor *src,
|
||||
ClutterColor *dest,
|
||||
gdouble shade);
|
||||
void clutter_color_lighten (const ClutterColor *src,
|
||||
ClutterColor *dest);
|
||||
void clutter_color_darken (const ClutterColor *src,
|
||||
ClutterColor *dest);
|
||||
void clutter_color_shade (const ClutterColor *src,
|
||||
ClutterColor *dest,
|
||||
gdouble shade);
|
||||
|
||||
void clutter_color_to_hls (const ClutterColor *src,
|
||||
guint8 *hue,
|
||||
guint8 *luminance,
|
||||
guint8 *saturation);
|
||||
void clutter_color_from_hls (ClutterColor *dest,
|
||||
guint8 hue,
|
||||
guint8 luminance,
|
||||
guint8 saturation);
|
||||
void clutter_color_to_hls (const ClutterColor *src,
|
||||
guint8 *hue,
|
||||
guint8 *luminance,
|
||||
guint8 *saturation);
|
||||
void clutter_color_from_hls (ClutterColor *dest,
|
||||
guint8 hue,
|
||||
guint8 luminance,
|
||||
guint8 saturation);
|
||||
|
||||
guint32 clutter_color_to_pixel (const ClutterColor *src);
|
||||
void clutter_color_from_pixel (ClutterColor *dest,
|
||||
guint32 pixel);
|
||||
guint32 clutter_color_to_pixel (const ClutterColor *src);
|
||||
void clutter_color_from_pixel (ClutterColor *dest,
|
||||
guint32 pixel);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user