Top | ![]() |
![]() |
![]() |
![]() |
void | gwy_gradient_get_color () |
const guchar * | gwy_gradient_get_samples () |
guchar * | gwy_gradient_sample () |
gint | gwy_gradient_get_npoints () |
GwyGradientPoint | gwy_gradient_get_point () |
void | gwy_gradient_set_point () |
void | gwy_gradient_set_point_color () |
void | gwy_gradient_insert_point () |
gint | gwy_gradient_insert_point_sorted () |
void | gwy_gradient_delete_point () |
void | gwy_gradient_reset () |
const GwyGradientPoint * | gwy_gradient_get_points () |
void | gwy_gradient_set_points () |
void | gwy_gradient_set_from_samples () |
GwyInventory * | gwy_gradients () |
GwyGradient * | gwy_gradients_get_gradient () |
#define | GWY_GRADIENT_DEFAULT |
GwyGradientPoint | |
struct | GwyGradient |
struct | GwyGradientClass |
Gradient is a map from interval [0,1] to RGB(A) color space. Each gradient is defined by an ordered set of color
points, the first of them is always at 0.0, the last at 1.0 (thus each gradient must consist of at least two
points). Between them, the color is interpolated. Color points of modifiable gradients (see GwyResource) can be
edited with functions like gwy_gradient_insert_point()
, gwy_gradient_set_point_color()
, or
gwy_gradient_set_points()
.
Gradient objects can be obtained from gwy_gradients_get_gradient()
. New gradients can be created with
gwy_inventory_new_item()
on the GwyInventory returned by gwy_gradients()
.
void gwy_gradient_get_color (GwyGradient *gradient
,gdouble x
,GwyRGBA *color
);
Computes the color at a given position of a color gradient.
const guchar * gwy_gradient_get_samples (GwyGradient *gradient
,gint *nsamples
);
Returns color gradient sampled to integers in Gdk pixbuf-like scheme.
The returned samples are owned by gradient
and must not be modified or freed. Changing the gradient may make the
returned pointer invalid, as does by gwy_resource_release()
.
guchar * gwy_gradient_sample (GwyGradient *gradient
,gint nsamples
,guchar *samples
);
Samples a gradient to an array Gdk pixbuf-like samples.
If samples
is not NULL
, it's resized to 4*nsamples
bytes, otherwise a new buffer is allocated.
If you don't have a reason for specific sample size (and are not going to modify the samples or otherwise dislike
the automatic resampling on gradient definition change), use gwy_gradient_get_samples()
instead. This function does
not need the gradient to be in use, though.
gint
gwy_gradient_get_npoints (GwyGradient *gradient
);
Returns the number of points in a color gradient.
GwyGradientPoint gwy_gradient_get_point (GwyGradient *gradient
,gint i
);
Returns the point at given index of a color gradient.
void gwy_gradient_set_point (GwyGradient *gradient
,gint i
,const GwyGradientPoint *point
);
Sets a single color point in a color gradient.
It is an error to try to move points beyond its neighbours, or to move first (or last) point from 0 (or 1).
void gwy_gradient_set_point_color (GwyGradient *gradient
,gint i
,const GwyRGBA *color
);
Sets the color of a color gradient point without moving it.
void gwy_gradient_insert_point (GwyGradient *gradient
,gint i
,const GwyGradientPoint *point
);
Inserts a point to a color gradient.
It is an error to try to position a outside its future neighbours, or to move the first (or last) point from 0 (or
1). Consider gwy_gradient_insert_point_sorted()
if you have the position and want the index to be determined
automatically.
gint gwy_gradient_insert_point_sorted (GwyGradient *gradient
,const GwyGradientPoint *point
);
Inserts a point into a color gradient based on its x position.
void gwy_gradient_delete_point (GwyGradient *gradient
,gint i
);
Deletes a point at given index in a color gradient.
It is not possible to delete points in gradients with less than 3 points. The first and last points should not be
deleted unless there's another point with x
= 0 or x
= 1 present.
void
gwy_gradient_reset (GwyGradient *gradient
);
Resets a gradient to the default two-point gray scale state.
const GwyGradientPoint * gwy_gradient_get_points (GwyGradient *gradient
,gint *npoints
);
Returns the complete set of color points of a gradient.
void gwy_gradient_set_points (GwyGradient *gradient
,gint npoints
,const GwyGradientPoint *points
);
Sets the complete color gradient definition to a given set of points.
The point positions should be ordered, and first point should start at 0.0, last end at 1.0. There should be no redundant points.
void gwy_gradient_set_from_samples (GwyGradient *gradient
,gint nsamples
,const guchar *samples
,gdouble threshold
);
Reconstructs a color gradient definition from sampled colors.
The result is usually approximate.
gradient |
A color gradient. |
|
nsamples |
Number of samples, it must be at least one. |
|
samples |
Sampled color gradient in Gdk pixbuf-like RRGGBBAA form. |
|
threshold |
Maximum allowed difference (for color components in range 0..1). When negative, default value 1/80 suitable for most purposes is used. |
GwyGradient *
gwy_gradients_get_gradient (const gchar *name
);
Convenience function to get a gradient from gwy_gradients()
by name.
#define GWY_GRADIENT_DEFAULT "Gray"
The name of the default gray color gradient.
It is guaranteed to always exist.
Note this is not the same as user's default gradient which corresponds to the default item in gwy_gradients()
inventory and it changes over time.
typedef struct { gdouble x; GwyRGBA color; } GwyGradientPoint;
Gradient color point struct.
Drawing data with gradients, GwyInventory -- the container holding all gradients, GwyDataView -- 2D data display widget, GwyColorAxis -- false color axis widget