Color Handling

Color Handling — various functions for color conversion / handling

Functions

Types and Values

struct LwHSL

Object Hierarchy

    GBoxed
    ╰── LwHSL

Description

The following functions provide support for converting colors from one color model to another color model. There are also some functions for getting/setting GdkRGBA objects from/to GSettings strings.

Functions

lw_color_get_color_mapping ()

gboolean
lw_color_get_color_mapping (GValue *value,
                            GVariant *variant,
                            gpointer p);

This function is used to convert a color from a GSettings string to a GdkRGBA object. Use this function as get mapping function of g_settings_bind_with_mapping() or take a look at the lw_settings_bind_color() macro.

Parameters

value

Return location for the property value

 

variant

The GVariant

 

p

User data that was specified when the binding was created

 

Returns

TRUE if the conversion succeeded, FALSE in case of an error


lw_color_set_color_mapping ()

GVariant *
lw_color_set_color_mapping (const GValue *value,
                            const GVariantType *type,
                            gpointer p);

This function is used to convert a GdkRGBA object to a GSettings string. Use this function as set mapping function of g_settings_bind_with_mapping() or take a look at the lw_settings_bind_color() macro.

Parameters

value

A GValue containing the property value to map

 

type

The GVariantType to create

 

p

User data that was specified when the binding was created

 

Returns

A new GVariant holding the data from value, or NULL in case of an error


lw_hsl_copy ()

LwHSL *
lw_hsl_copy (const LwHSL *hsl);

Makes a copy of a LwHSL structure.

Parameters

hsl

A LwHSL

 

Returns

A newly allocated LwHSL. It should be freed through lw_hsl_free().

Since: 0.4


lw_hsl_free ()

void
lw_hsl_free (LwHSL *hsl);

Frees a LwHSL structure created with lw_hsl_copy().

Parameters

hsl

A LwHSL

 

Since: 0.4


lw_hsl_to_rgb ()

GdkRGBA *
lw_hsl_to_rgb (LwHSL *hsl);

Converts a color from the HSL color model to the RGB color model. The alpha value of the result will be undefined.

Parameters

hsl

A LwHSL

 

Returns

A newly allocated GdkRGBA. It should be freed through gdk_rgba_free().


lw_rgb_to_hsl ()

LwHSL *
lw_rgb_to_hsl (GdkRGBA *rgb);

Converts a color from the RGB color model to the HSL color model. The alpha value of the rgb param is not used by this function.

Parameters

rgb

A GdkRGBA

 

Returns

A newly allocated LwHSL. It should be freed through lw_hsl_free().

Types and Values

struct LwHSL

struct LwHSL {
	gdouble hue;
	gdouble saturation;
	gdouble lightness;
};

This structure represents a color in HSL color space.

Members

gdouble hue;

The hue value from 0.0 to 1.0

 

gdouble saturation;

The saturation value from 0.0 to 1.0

 

gdouble lightness;

The lightness value from 0.0 to 1.0

 

Since: 0.4