GRADIENT_RECT ​
Fills a rectangular shape with smooth, shaded colors.
Syntax ​
GRADIENT_RECT [ x:measureValue ] [ y:measureValue ] [ w:measureValue ] [ h:measureValue ]
[ style:GradientMode ] [ color1:ColorSpec ] [ color2:ColorSpec ] [ color3:ColorSpec ] [ color4:ColorSpec ] .
GradientMode : horz | vert | updiag | downdiag | diagcross .
Parameters ​
x
(measureValue, optional) - The x-coordinate of the top-left corner of the rectangle. The default is0cm
.y
(measureValue, optional) - The y-coordinate of the top-left corner of the rectangle. The default is0cm
.w
(measureValue, optional) - The width of the rectangle. The default is0cm
.h
(measureValue, optional) - The height of the rectangle. The default is0cm
.style
(modifier, optional) - The direction of the color gradient. The default isdiagcross
.color1
(ColorSpec, optional) - The first color used for the gradient. The default is"black"
.color2
(ColorSpec, optional) - The second color used for the gradient. The default is"black"
.color3
(ColorSpec, optional) - The color used for the bottom-right corner of the gradient with thediagcross
style. The default is"black"
.color4
(ColorSpec, optional) - The color used for the bottom-left corner of the gradient with thediagcross
style. The default is"black"
.
Details ​
This command does not draw an outline. It is not influenced by any style commands.
The direction of the gradient depends on the value of the style
parameter:
horz
: from the left withcolor1
to the right withcolor2
.vert
: from the top withcolor1
to the bottom withcolor2
.updiag
: from the bottom-left corner withcolor1
to the top-right corner withcolor2
.downdiag
: from the top-left corner withcolor1
to the bottom-right corner withcolor2
.diagcross
: four-color shading with one color per corner:color1
in the top-left,color2
in the top-right,color3
bottom-right andcolor4
in the bottom-left corners.
Colors are specified through a ColorSpec
, which has to evaluate to a strValue
or an intValue
(see LEO Colors for details).
To draw a border around the gradient two more commands are needed: FILL style:null
followed by a RECTANGLE
(using the current PEN setting) with the same coordinates as GRADIENT_RECT
.
The command GRADIENT_RECT style:diagcross
is not fully supported in SVG Graphics. Instead of the original ones, SVG-specific algorithms are used, yielding very similar results.
Rotation of a gradient rectangle is not possible. This has an influence on the drawing of relations where a rectangle's shape will change with different rotations. If a rotation is necessary then use two GRADIENT_TRI
commands instead.
See Also ​
- CLIP_ELLIPSE
- CLIP_OFF
- CLIP_PATH
- CLIP_POLY
- CLIP_RECT
- CLIP_ROUNDPOLY
- CLIP_ROUNDRECT
- FILL
- GRADIENT_TRI
- PEN
- RECTANGLE
Examples ​
Draw a dark violet rectangle with a downwards diagonal gradient and without any outline.
GRAPHREP
GRADIENT_RECT x:-1.4cm y:-0.7cm w:2.8cm h:1.4cm style:downdiag color1:"$666699" color2:"$444466"
Draw a rectangle with an outline and an upwards diagonal gradient filling from yellow to red.
GRAPHREP
# Note: SHADOW is on by default.
GRADIENT_RECT x:-1.4cm y:-0.7cm w:2.8cm h:1.4cm style:updiag color1:"yellow" color2:"red"
PEN w:0.05cm
FILL style:null
RECTANGLE x:-1.4cm y:-0.7cm w:2.8cm h:1.4cm
Draw the different styles of gradient rectangles with varying colors and write the style in the middle of each rectangle.
GRAPHREP
GRADIENT_RECT x:-5.2cm y:-0.6cm w:2cm h:1.2cm style:horz color1:"mistyrose" color2:"salmon"
TEXT "horz" x:-4.2cm w:c h:c
GRADIENT_RECT x:-3.1cm y:-0.6cm w:2cm h:1.2cm style:vert color1:"peachpuff" color2:"orange"
TEXT "vert" x:-2.1cm w:c h:c
GRADIENT_RECT x:-1cm y:-0.6cm w:2cm h:1.2cm style:updiag color1:"honeydew" color2:"green"
TEXT "updiag" x:0cm w:c h:c
GRADIENT_RECT x:1.1cm y:-0.6cm w:2cm h:1.2cm style:downdiag color1:"paleturquoise" color2:"cadetblue"
TEXT "downdiag" x:2.1cm w:c h:c
GRADIENT_RECT x:3.2cm y:-0.6cm w:2cm h:1.2cm style:diagcross color1:"powderblue" color2:"steelblue" color3:"thistle" color4:"darkviolet"
TEXT "diagcross" x:4.2cm w:c h:c
Draw an ellipse with a gradient filling and a shadow.
GRAPHREP
# Note: SHADOW is on by default.
# Clip the ellipse region.
CLIP_ELLIPSE rx:-1.4cm ry:-0.7cm
# Draw the gradient.
GRADIENT_RECT x:-1.4cm y:-0.7cm w:2.8cm h:1.4cm style:downdiag color1:"sandybrown" color2:"skyblue"
# Turn off the clipping region.
CLIP_OFF
# Draw the ellipse outline.
FILL style:null
ELLIPSE rx:-1.4cm ry:-0.7cm
Versions and Changes ​
Available since ADOxx 1.3