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

Class Gradient


Gradient struct contains private data only and should be accessed using the functions below.
Method Summary
  delete_point(index_)
Deletes a point at given index in a color gradient.
  get_color(x, color)
Computes the color at a given position of a color gradient.
  get_npoints()
Returns: The number of points in gradient.
  reset()
Resets a gradient to the default two-point gray scale state.
  sample(nsamples, samples)
Samples a gradient to an array GdkPixbuf-like samples.
  sample_to_pixbuf(pixbuf)
Samples a color gradient to a provided pixbuf.
  set_from_samples(nsamples, samples, threshold)
Reconstructs a color gradient definition from sampled colors.
  set_point(index_, point)
Sets a single color point in a color gradient.
  set_point_color(index_, color)
Sets the color of a color gradient point without moving it.
  UNIMPLEMENTED_get_point(index_)
Returns: Color point at index_.
  UNIMPLEMENTED_get_points(npoints)
Returns: Complete set gradient's color points.
  UNIMPLEMENTED_get_samples(nsamples)
Returns: Sampled gradient as a sequence of GdkPixbuf-like RRGGBBAA
  UNIMPLEMENTED_insert_point(index_, point)
Inserts a point to a color gradient.
  UNIMPLEMENTED_insert_point_sorted(point)
Inserts a point into a color gradient based on its x position.
  UNIMPLEMENTED_set_points(npoints, points)
Sets the complete color gradient definition to a given set of points.

Method Details

delete_point(index_)

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)

get_color(x, color)

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)

get_npoints()

Returns: The number of points in gradient.
Returns:
The number of points in gradient.

reset()

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

sample(nsamples, samples)

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)

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

set_from_samples(nsamples, samples, threshold)

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)

set_point(index_, 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).
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)

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_get_point(index_)

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

UNIMPLEMENTED_get_points(npoints)

Returns: Complete set gradient's color points. The returned array is
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_get_samples(nsamples)

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

UNIMPLEMENTED_insert_point(index_, 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).
Parameters:
index_ - Color point index in gradient. (int)
point - Color point to insert at index_. (const-GradientPoint*)

UNIMPLEMENTED_insert_point_sorted(point)

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.

UNIMPLEMENTED_set_points(npoints, 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.
Parameters:
npoints - The length of points. (int)
points - Color points to set as new gradient definition. (const-GradientPoint*)

Generated by Epydoc 2.1 on Tue Dec 30 04:01:42 2008 http://epydoc.sf.net