Scroll to navigation

Prima::Drawable::Gradient(3) User Contributed Perl Documentation Prima::Drawable::Gradient(3)

NAME

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

DESCRIPTION

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

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

SYNOPSIS

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

API

Methods

Creates a new gradient object with %OPTIONS replaced.
Creates a new gradient object. The following %OPTIONS are available:
When set, applies not only gradient colors but also different fill patterns to create an even smoother transition effect between adjacent colors. Works significantly slower.
Each color is a "cl::" value. The gradient is calculated as a polyline where each of its vertices corresponds to a certain blend between two adjacent colors in the palette. F.ex. the simplest palette going from "cl::White" to "cl::Black" over a transition line 0..1 (default), produces a pure white color at the start and a pure black color at the end, with all available shades of gray in between.
A set of 2-integer polyline vertices where the first integer is a coordinate (x, y, or whatever is 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 the same purpose as the "poly" option but the vertices are projected first to a B-spline curve using render_spline and %OPTIONS. The resulting polyline is treated as "poly".
Only used in the bar primitive, to set the gradient direction.
Points to the widget class to resolve generic colors like "cl::Back" that may differ between widget classes.

See also: bar, stripes .

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

Context used: fillPattern, rop, rop2

Returns a list of gradient colors for each step from 1 to BREADTH. When "dither" is set, each color is an array of three items, - the two adjacent colors and an integer value between 0 and 63 that reflects the amount of blending needed between the colors.
Draws a filled ellipse with the center in (X,Y) and diameters (DIAM_X,DIAM_Y)

Context used: fillPattern, rop, rop2

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

Context used: fillPattern, rop, rop2

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

2024-02-01 perl v5.38.2