Prima::Drawable::Gradient - gradient fills for primitives
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.
Prima::Drawable
new_gradient
$canvas-> new_gradient( palette => [ cl::White, cl::Blue, cl::White ], )-> sector(50,50,100,100,0,360);
Here are %OPTIONS understood in the gradient request:
Creates a new gradient object with %OPTIONS replaced.
Points to a widget class to resolve generic colors like cl::Back, that may differ from widget class to widget class.
cl::Back
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.
cl::
cl::White
cl::Black
0..1
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))
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.
poly
%OPTIONS
Only used in bar, to set gradient direction.
See also: bar, stripes .
Draws a filled rectangle within (X1,Y1) - (X2,Y2) extents
Context used: fillPattern, rop, rop2
Returns a list of gradient colors for each step from 1 to BREADTH.
Draws a filled ellipse with center in (X,Y) and diameters (DIAM_X,DIAM_Y)
Draws a filled sector with center in (X,Y) and diameters (DIAM_X,DIAM_Y) from START_ANGLE to END_ANGLE
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 )
Dmitry Karasik, <dmitry@karasik.eu.org>.
Prima::Drawable, examples/f_fill.pl, examples/gradient.pl
To install Prima, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Prima
CPAN shell
perl -MCPAN -e shell install Prima
For more information on module installation, please visit the detailed CPAN module installation guide.