GtkGradient

GtkGradient — Gradients

Synopsis

#include <gtk/gtk.h>

                    GtkGradient;
GtkGradient *       gtk_gradient_new_linear             (gdouble x0,
                                                         gdouble y0,
                                                         gdouble x1,
                                                         gdouble y1);
GtkGradient *       gtk_gradient_new_radial             (gdouble x0,
                                                         gdouble y0,
                                                         gdouble radius0,
                                                         gdouble x1,
                                                         gdouble y1,
                                                         gdouble radius1);
void                gtk_gradient_add_color_stop         (GtkGradient *gradient,
                                                         gdouble offset,
                                                         GtkSymbolicColor *color);
GtkGradient *       gtk_gradient_ref                    (GtkGradient *gradient);
void                gtk_gradient_unref                  (GtkGradient *gradient);
gboolean            gtk_gradient_resolve                (GtkGradient *gradient,
                                                         GtkStyleProperties *props,
                                                         cairo_pattern_t **resolved_gradient);

Description

GtkGradient is a boxed type that represents a gradient. It is the result of parsing a gradient expression. To obtain the gradient represented by a GtkGradient, it has to be resolved with gtk_gradient_resolve(), which replaces all symbolic color references by the colors they refer to (in a given context) and constructs a cairo_pattern_t value.

It is not normally necessary to deal directly with GtkGradients, since they are mostly used behind the scenes by GtkStyleContext and GtkCssProvider.

Details

GtkGradient

typedef struct _GtkGradient GtkGradient;


gtk_gradient_new_linear ()

GtkGradient *       gtk_gradient_new_linear             (gdouble x0,
                                                         gdouble y0,
                                                         gdouble x1,
                                                         gdouble y1);

Creates a new linear gradient along the line defined by (x0, y0) and (x1, y1). Before using the gradient a number of stop colors must be added through gtk_gradient_add_color_stop().

x0 :

X coordinate of the starting point

y0 :

Y coordinate of the starting point

x1 :

X coordinate of the end point

y1 :

Y coordinate of the end point

Returns :

A newly created GtkGradient

Since 3.0


gtk_gradient_new_radial ()

GtkGradient *       gtk_gradient_new_radial             (gdouble x0,
                                                         gdouble y0,
                                                         gdouble radius0,
                                                         gdouble x1,
                                                         gdouble y1,
                                                         gdouble radius1);

Creates a new radial gradient along the two circles defined by (x0, y0, radius0) and (x1, y1, radius1). Before using the gradient a number of stop colors must be added through gtk_gradient_add_color_stop().

x0 :

X coordinate of the start circle

y0 :

Y coordinate of the start circle

radius0 :

radius of the start circle

x1 :

X coordinate of the end circle

y1 :

Y coordinate of the end circle

radius1 :

radius of the end circle

Returns :

A newly created GtkGradient

Since 3.0


gtk_gradient_add_color_stop ()

void                gtk_gradient_add_color_stop         (GtkGradient *gradient,
                                                         gdouble offset,
                                                         GtkSymbolicColor *color);

Adds a stop color to gradient.

gradient :

a GtkGradient

offset :

offset for the color stop

color :

color to use

Since 3.0


gtk_gradient_ref ()

GtkGradient *       gtk_gradient_ref                    (GtkGradient *gradient);

Increases the reference count of gradient.

gradient :

a GtkGradient

Returns :

The same gradient

Since 3.0


gtk_gradient_unref ()

void                gtk_gradient_unref                  (GtkGradient *gradient);

Decreases the reference count of gradient, freeing its memory if the reference count reaches 0.

gradient :

a GtkGradient

Since 3.0


gtk_gradient_resolve ()

gboolean            gtk_gradient_resolve                (GtkGradient *gradient,
                                                         GtkStyleProperties *props,
                                                         cairo_pattern_t **resolved_gradient);

If gradient is resolvable, resolved_gradient will be filled in with the resolved gradient as a cairo_pattern_t, and TRUE will be returned. Generally, if gradient can't be resolved, it is due to it being defined on top of a named color that doesn't exist in props.

gradient :

a GtkGradient

props :

GtkStyleProperties to use when resolving named colors

resolved_gradient :

return location for the resolved pattern. [out]

Returns :

TRUE if the gradient has been resolved

Since 3.0