Gradients

Informations

Author: Andreas Würmser
License: Freeware

Description

Paints linear and radial gradients as well as multi-color gradients (coons patch meshes) inside a rectangle.

LinearGradient(float x, float y, float w, float h, array col1, array col2 [, array coords])

x: abscissa of the top left corner of the rectangle.
y: ordinate of the top left corner of the rectangle.
w: width of the rectangle.
h: height of the rectangle.
col1: first color (RGB components).
col2: second color (RGB components).
coords: array of the form (x1, y1, x2, y2) which defines the gradient vector (see linear_gradient_coords.jpg). The default value is from left to right (x1=0, y1=0, x2=1, y2=0).

RadialGradient(float x, float y, float w, float h, array col1, array col2 [, array coords])

x: abscissa of the top left corner of the rectangle.
y: ordinate of the top left corner of the rectangle.
w: width of the rectangle.
h: height of the rectangle.
col1: first color (RGB components).
col2: second color (RGB components).
coords: array of the form (fx, fy, cx, cy, r) where (fx, fy) is the starting point of the gradient with color1, (cx, cy) is the center of the circle with color2, and r is the radius of the circle (see radial_gradient_coords.jpg). (fx, fy) should be inside the circle, otherwise some areas will not be defined.

CoonsPatchMesh(float x, float y, float w, float h, array col1, array col2, array col3, array col4 [, array coords [, float coords_min [, float coords_max]]])

x: abscissa of the top left corner of the rectangle.
y: ordinate of the top left corner of the rectangle.
w: width of the rectangle.
h: height of the rectangle.
col1: first color (lower left corner) (RGB components).
col2: second color (lower right corner) (RGB components).
col3: third color (upper right corner) (RGB components).
col4: fourth color (upper left corner) (RGB components).
coords:

- for one patch mesh

array(float x1, float y1, .... float x12, float y12): 12 pairs of coordinates (normally from 0 to 1) which specify the Bézier control points that define the patch. First pair is the lower left edge point, next is its right control point (control point 2). Then the other points are defined in the order: control point 1, edge point, control point 2 going counter-clockwise around the patch. Last (x12, y12) is the first edge point's left control point (control point 1).

- for two or more patch meshes

array[number of patches]: arrays with the following keys for each patch:
f: where to put that patch (0 = first patch, 1, 2, 3 = right, top and left of precedent patch - I didn't figure this out completely - just try and error ;-)
points: 12 pairs of coordinates of the Bézier control points as above for the first patch, 8 pairs of coordinates for the following patches, ignoring the coordinates already defined by the precedent patch (I also didn't figure out the order of these - also: try and see what's happening)
colors: must be 4 colors for the first patch, 2 colors for the following patches

coords_min: minimum value used by the coordinates. If a coordinate's value is smaller than this it will be cut to coords_min. default: 0
coords_max: maximum value used by the coordinates. If a coordinate's value is greater than this it will be cut to coords_max. default: 1