NAME

Prima::Drawable::Gradient - gradient fills for primitives

DESCRIPTION

Prima offers primitive gradient services to draw gradually changing colors. A gradient is requested by setting of at least two colors and optionally a set of quadratic spline points that, when, projected, generate the transition curve between the colors.

The module augments the Prima::Drawable drawing functionality by adding new_gradient function.

SYNOPSIS

$canvas-> new_gradient(
	palette => [ cl::White, cl::Blue, cl::White ],
)-> sector(50,50,100,100,0,360);

API

Methods

new $CANVAS, %OPTIONS

Here are %OPTIONS understood in the gradient request:

clone %OPTIONS

Creates a new gradient object with %OPTIONS replaced.

widgetClass INTEGER

Points to a widget class to resolve generic colors like cl::Back, that may differ from widget class to widget class.

palette @COLORS

Each color is a cl:: value. The gradient is calculated as polyline where each its vertex corresponds to a certain blend between two neighbouring colors in the palette. F.ex. the simplest palette going from cl::White to cl::Black over a polyline 0..1 (default), produces pure white color at the start and pure black color at the end, filling all available shades of gray in between, and changing monotonically.

poly @VERTICES

Set of 2-integer polyline vertexes where the first integer is a coordinate (x, y, or whatever required by the drawing primitive) between 0 and 1, and the second is the color blend value between 0 and 1.

Default: ((0,0),(1,1))

spline \@VERTICES, %OPTIONS

Serving same purpose as poly but vertexes are projected first to a B-spline curve using render_spline and %OPTIONS. The resulting polyline is treated as poly.

vertical BOOLEAN

Only used in bar, to set gradient direction.

See also: bar, stripes .

bar X1, Y1, X2, Y2, VERTICAL = 0

Draws a filled rectangle within (X1,Y1) - (X2,Y2) extents

Context used: fillPattern, rop, rop2

colors BREADTH

Returns a list of gradient colors for each step from 1 to BREADTH.

ellipse X, Y, DIAM_X, DIAM_Y

Draws a filled ellipse with center in (X,Y) and diameters (DIAM_X,DIAM_Y)

Context used: fillPattern, rop, rop2

sector X, Y, DIAM_X, DIAM_Y, START_ANGLE, END_ANGLE

Draws a filled sector with center in (X,Y) and diameters (DIAM_X,DIAM_Y) from START_ANGLE to END_ANGLE

Context used: fillPattern, rop, rop2

stripes BREADTH

Returns an array consisting of integer pairs, where the first one is a color value, and the second is the breadth of the color strip. bar uses this information to draw a gradient fill, where each color strip is drawn with its own color. Can be used for implementing other gradient-aware primitives (see examples/f_fill.pl )

AUTHOR

Dmitry Karasik, <dmitry@karasik.eu.org>.

SEE ALSO

Prima::Drawable, examples/f_fill.pl, examples/gradient.pl