Prima::...Gradient(3)

πŸ“¦
version 1.74000 Β· 5 versions
, in opensuse-leap 16.0

πŸ’– NAME πŸ’–

Prima::Drawable::Gradient β€” gradient fills for primitives

Okay bestie, this manual page is Prima::...Gradient(3) from the User Contributed Perl Documentation, and it's here to make your primitives fade like a main character. πŸ’…βœ¨


🌈 DESCRIPTION 🌈

Prima has simple gradient services for drawing colors that gradually change. You make a gradient 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 πŸ› οΈ

  • clone %OPTIONS β€” Creates a new gradient object with %OPTIONS replaced.
  • new $CANVAS, %OPTIONS β€” Creates a new gradient object. These are the %OPTIONS available:
    • dither BOOLEAN = 0 β€” When set, it applies not only gradient colors but also different fill patterns, creating an even smoother transition effect between adjacent colors. It works significantly slower.
    • palette @COLORS β€” 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.
    • poly @VERTICES β€” 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))
    • spline \@VERTICES, %OPTIONS β€” 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.
    • vertical BOOLEAN β€” Only used in the bar primitive, to set the gradient direction.
    • widgetClass INTEGER β€” Points to the widget class to resolve generic colors like cl::Back that may differ between widget classes.

Also see bar and stripes.

  • bar X1, Y1, X2, Y2, VERTICAL = 0 β€” Draws a filled rectangle with (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. 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.
  • ellipse X, Y, DIAM_X, DIAM_Y β€” Draws a filled ellipse with the 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 the 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 🌟

The author is Dmitry Karasik, <dmitry@karasik.eu.org>.


πŸ¦‹ SEE ALSO πŸ¦‹

Go peek at Prima::Drawable, examples/f_fill.pl, and examples/gradient.pl.


Sign-off: this page is perl v5.42.0, dated 2024-08-20, and filed under Prima::...Gradient(3). Stay gradient, bestie πŸ’–πŸ«Ά

πŸ“¦ where this page comes from