Colors

Colors — Manipulation of colors

Functions

CdkColor * cdk_color_copy ()
void cdk_color_free ()
gboolean cdk_color_parse ()
gboolean cdk_color_equal ()
guint cdk_color_hash ()
gchar * cdk_color_to_string ()

Types and Values

Includes

#include <cdk/cdk.h>

Description

A CdkColor represents a color.

When working with cairo, it is often more convenient to use a CdkRGBA instead.

Functions

cdk_color_copy ()

CdkColor *
cdk_color_copy (const CdkColor *color);

Makes a copy of a CdkColor.

The result must be freed using cdk_color_free().

Parameters

color

a CdkColor

 

Returns

a copy of color


cdk_color_free ()

void
cdk_color_free (CdkColor *color);

Frees a CdkColor created with cdk_color_copy().

Parameters

color

a CdkColor

 

cdk_color_parse ()

gboolean
cdk_color_parse (const gchar *spec,
                 CdkColor *color);

Parses a textual specification of a color and fill in the red , green , and blue fields of a CdkColor.

The string can either one of a large set of standard names (taken from the X11 rgb.txt file), or it can be a hexadecimal value in the form “#rgb” “#rrggbb”, “#rrrgggbbb” or “#rrrrggggbbbb” where “r”, “g” and “b” are hex digits of the red, green, and blue components of the color, respectively. (White in the four forms is “#fff”, “#ffffff”, “#fffffffff” and “#ffffffffffff”).

Parameters

spec

the string specifying the color

 

color

the CdkColor to fill in.

[out]

Returns

TRUE if the parsing succeeded


cdk_color_equal ()

gboolean
cdk_color_equal (const CdkColor *colora,
                 const CdkColor *colorb);

Compares two colors.

Parameters

colora

a CdkColor

 

colorb

another CdkColor

 

Returns

TRUE if the two colors compare equal


cdk_color_hash ()

guint
cdk_color_hash (const CdkColor *color);

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

Parameters

color

a CdkColor

 

Returns

The hash function applied to color


cdk_color_to_string ()

gchar *
cdk_color_to_string (const CdkColor *color);

Returns a textual specification of color in the hexadecimal form “#rrrrggggbbbb” where “r”, “g” and “b” are hex digits representing the red, green and blue components respectively.

The returned string can be parsed by cdk_color_parse().

Parameters

color

a CdkColor

 

Returns

a newly-allocated text string

Since: 2.12

Types and Values

CdkColor

typedef struct {
  guint32 pixel;
  guint16 red;
  guint16 green;
  guint16 blue;
} CdkColor;

A CdkColor is used to describe a color, similar to the XColor struct used in the X11 drawing API.

Members

guint32 pixel;

For allocated colors, the pixel value used to draw this color on the screen. Not used anymore.

 

guint16 red;

The red component of the color. This is a value between 0 and 65535, with 65535 indicating full intensity

 

guint16 green;

The green component of the color

 

guint16 blue;

The blue component of the color