RGBA Colors

RGBA Colors — RGBA colors

Synopsis

#include <gdk/gdk.h>

                    GdkRGBA;
GdkRGBA *           gdk_rgba_copy                       (GdkRGBA *rgba);
void                gdk_rgba_free                       (GdkRGBA *rgba);
gboolean            gdk_rgba_parse                      (const gchar *spec,
                                                         GdkRGBA *rgba);
gboolean            gdk_rgba_equal                      (gconstpointer p1,
                                                         gconstpointer p2);
guint               gdk_rgba_hash                       (gconstpointer p);
gchar *             gdk_rgba_to_string                  (const GdkRGBA *rgba);

Description

Details

GdkRGBA

typedef struct {
  gdouble red;
  gdouble green;
  gdouble blue;
  gdouble alpha;
} GdkRGBA;


gdk_rgba_copy ()

GdkRGBA *           gdk_rgba_copy                       (GdkRGBA *rgba);

Makes a copy of a GdkRGBA structure, the result must be freed through gdk_rgba_free().

rgba :

a GdkRGBA

Returns :

A newly allocated GdkRGBA

gdk_rgba_free ()

void                gdk_rgba_free                       (GdkRGBA *rgba);

Frees a GdkRGBA struct created with gdk_rgba_copy()

rgba :

a GdkRGBA

gdk_rgba_parse ()

gboolean            gdk_rgba_parse                      (const gchar *spec,
                                                         GdkRGBA *rgba);

Parses a textual representation of a color, filling in the red, green, blue and alpha fields of the rgba struct.

The string can be either one of:

  • A standard name (Taken from the X11 rgb.txt file).
  • A hex value in the form 'rgb' 'rrggbb' 'rrrgggbbb' or 'rrrrggggbbbb'
  • A RGB color in the form 'rgb(r,g,b)' (In this case the color will have full opacity)
  • A RGBA color in the form 'rgba(r,g,b,a)'

Where 'r', 'g', 'b' and 'a' are respectively the red, green, blue and alpha color values, parsed in the last 2 cases as double numbers in the range [0..1], any other value out of that range will be clamped.

spec :

the string specifying the color

rgba :

the GdkRGBA struct to fill in

Returns :

TRUE if the parsing succeeded

gdk_rgba_equal ()

gboolean            gdk_rgba_equal                      (gconstpointer p1,
                                                         gconstpointer p2);

Compares two RGBA colors.

p1 :

a GdkRGBA pointer.

p2 :

another GdkRGBA pointer.

Returns :

TRUE if the two colors compare equal

gdk_rgba_hash ()

guint               gdk_rgba_hash                       (gconstpointer p);

A hash function suitable for using for a hash table that stores GdkRGBAs.

p :

a GdkRGBA pointer.

Returns :

The hash function applied to p

gdk_rgba_to_string ()

gchar *             gdk_rgba_to_string                  (const GdkRGBA *rgba);

Returns a textual specification of rgba in the form rgba (r, g, b, a), where 'r', 'g', 'b' and 'a' represent the red, green, blue and alpha values respectively.

rgba :

a GdkRGBA

Returns :

A newly allocated text string