Module gwy :: Class Gradient
[hide private]
[frames] | no frames]

Class Gradient

source code

Instance Methods [hide private]
 
get_color(x, color)
Computes the color at a given position of a color gradient.
source code
 
UNIMPLEMENTED_get_samples(nsamples)
Returns color gradient sampled to integers in GdkPixbuf-like scheme.
source code
 
sample(nsamples, samples)
Samples a gradient to an array GdkPixbuf-like samples.
source code
 
sample_to_pixbuf(pixbuf)
Samples a color gradient to a provided pixbuf.
source code
 
get_npoints()
Returns the number of points in a color gradient.
source code
 
UNIMPLEMENTED_get_point(index_)
Returns the point at given index of a color gradient.
source code
 
set_point(index_, point)
Sets a single color point in a color gradient.
source code
 
set_point_color(index_, color)
Sets the color of a color gradient point without moving it.
source code
 
UNIMPLEMENTED_insert_point(index_, point)
Inserts a point to a color gradient.
source code
 
UNIMPLEMENTED_insert_point_sorted(point)
Inserts a point into a color gradient based on its x position.
source code
 
delete_point(index_)
Deletes a point at given index in a color gradient.
source code
 
reset()
Resets a gradient to the default two-point gray scale state.
source code
 
UNIMPLEMENTED_get_points(npoints)
Returns the complete set of color points of a gradient.
source code
 
UNIMPLEMENTED_set_points(npoints, points)
Sets the complete color gradient definition to a given set of points.
source code
 
set_from_samples(nsamples, samples, threshold)
Reconstructs a color gradient definition from sampled colors.
source code
Method Details [hide private]

get_color(x, color)

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)

UNIMPLEMENTED_get_samples(nsamples)

source code 

Returns color gradient sampled to integers in GdkPixbuf-like scheme.

The returned samples are owned by gradient and must not be modified or freed. They are automatically updated when the gradient changes, although their number never changes. The returned pointer is valid only as long as the gradient used, indicated by Resource.use().

Parameters:
  • nsamples - A location to store the number of samples (or NULL). (int)
Returns:
Sampled gradient as a sequence of GdkPixbuf-like RRGGBBAA quadruplets.

sample(nsamples, samples)

source code 

Samples a gradient to an array GdkPixbuf-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 Gradient.get_samples() instead. This function does not need the gradient to be in use, though.

Parameters:
  • nsamples - Required number of samples. (int)
  • samples - Pointer to array to be filled. (guchar*)
Returns:
Sampled gradient as a sequence of GdkPixbuf-like RRGGBBAA quadruplets.

sample_to_pixbuf(pixbuf)

source code 

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). (GdkPixbuf*)

get_npoints()

source code 

Returns the number of points in a color gradient.

Returns:
The number of points in gradient.

UNIMPLEMENTED_get_point(index_)

source code 

Returns the point at given index of a color gradient.

Parameters:
  • index_ - Color point index in gradient. (int)
Returns:
Color point at index_.

set_point(index_, point)

source code 

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*)

set_point_color(index_, color)

source code 

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*)

UNIMPLEMENTED_insert_point(index_, point)

source code 

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).

Parameters:
  • index_ - Color point index in gradient. (int)
  • point - Color point to insert at index_. (const-GradientPoint*)

UNIMPLEMENTED_insert_point_sorted(point)

source code 

Inserts a point into a color gradient based on its x position.

Parameters:
  • point - Color point to insert. (const-GradientPoint*)
Returns:
The index point was inserted at.

delete_point(index_)

source code 

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)

reset()

source code 

Resets a gradient to the default two-point gray scale state.

UNIMPLEMENTED_get_points(npoints)

source code 

Returns the complete set of color points of a gradient.

Parameters:
  • npoints - A location to store the number of color points (or NULL). (int)
Returns:
Complete set gradient's color points. The returned array is owned by gradient and must not be modified or freed.

UNIMPLEMENTED_set_points(npoints, points)

source code 

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)