Class Gradient
source code
A map from numbers to RGBA colors
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 Resource
) can be
edited with functions like Gradient.insert_point
(), Gradient.set_point_color(), or Gradient.set_points().
Gradient objects can be obtained from gwy_gradients_get_gradient(). New gradients can be
created with Inventory.new_item() on the
Inventory
returned by gwy_gradients().
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reset()
Resets a gradient to the default two-point gray scale state. |
source code
|
|
|
|
|
set_points(npoints,
points)
Sets the complete color gradient definition to a given set of points. |
source code
|
|
|
|
Computes the color at a given position of a color gradient.
- Parameters:
x - Position in gradient, in range 0..1. (float)
color - Color to fill with interpolated color at position
x . (RGBA)
|
Samples a color gradient to a provided pixbuf.
Unlike Gradient.sample () which simply takes
samples at equidistant points this method uses supersampling and thus it
gives a bit better looking gradient presentation.
- Parameters:
pixbuf - A pixbuf to sample gradient to (in horizontal direction).
(gdk.Pixbuf )
|
Returns the number of points in a color gradient.
- Returns:
- The number of points in
gradient .
(int)
|
Returns the point at given index of a color gradient.
- Parameters:
index_ - Color point index in gradient . (int)
- Returns:
- Color point at
index_ . (GradientPoint)
|
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).
- Parameters:
index_ - Color point index in gradient . (int)
point - Color point to replace current point at
index_ with. (const-GradientPoint*)
|
Sets the color of a color gradient point without moving it.
- Parameters:
index_ - Color point index in gradient . (int)
color - Color to set the point to. (const-RGBA*)
|
Deletes a point at given index in a color gradient.
It is not possible to delete points in gradients with less than 3
points. First and last points should not be deleted unless there's
another point with x = 0 or x = 1
present.
- Parameters:
index_ - Color point index in gradient . (int)
|
Returns the complete set of color points of a gradient.
- Returns:
- Tuple consisting of 2 values (
value ,
npoints ). ((const-GradientPoint*),
(int))
|
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.
- Parameters:
npoints - The length of points . (int)
points - Color points to set as new gradient definition.
(const-GradientPoint*)
|
set_from_samples(nsamples,
samples,
threshold)
| source code
|
Reconstructs a color gradient definition from sampled colors.
The result is usually approximate.
- Parameters:
nsamples - Number of samples, it must be at least one. (int)
samples - Sampled color gradient in GdkPixbuf -like
RRGGBBAA form. (string)
threshold - Maximum allowed difference (for color components in range 0..1).
When negative, default value 1/80 suitable for most purposes is
used. (float)
|