Shape
From DocBase
Contents |
SHAPE
Draws shapes using the SHAPE sub-dialect
| Arg | Type | Description | Values |
|---|---|---|---|
| shape-cmd-block | [block!] |
Notes and Examples
For examples of specific SHAPE commands see HERE
ARC
Draws an elliptical arc from the current point.
|
pen yellow
line-width 3
shape [
move 100x200
arc 300x200 120 50 0
]
|
Set SWEEP to draw arcs in a "positive-angle" direction:
pen yellow
line-width 3
shape [
move 100x200
arc 300x200 120 50 0 sweep
]
Set LARGE for arc sweeps greater than 180°:
pen yellow
line-width 3
shape [
move 100x200
arc 300x200 120 50 0 sweep large
]
More complex usage of arc:
pen yellow
line-width 3
shape [
move 0x399
line 42x357
arc 84x315 25 20 -45 sweep
line 126x273
arc 168x231 25 40 -45 sweep
line 210x189
arc 252x147 25 60 -45 sweep
line 294x105
arc 336x63 25 80 -45 sweep
line 399x0
move 0x0
]
Same complex example but with relative positioning commands:
pen red
line-width 3
translate 0x399
shape [
move 0x0
'line 42x-42
'arc 42x-42 25 20 -45 sweep
'line 42x-42
'arc 42x-42 25 40 -45 sweep
'line 42x-42
'arc 42x-42 25 60 -45 sweep
'line 42x-42
'arc 42x-42 25 80 -45 sweep
'line 63x-63
move 0x0
]
CLOSE
Closes previously defined set of lines in the SHAPE block.
This command has no arguments.
Notes and Examples
In some case it is easier to use the CLOSE command as a shortcut instead of calculating the closing lines.
This is without CLOSE commands:
line-width 3
pen yellow
shape [
move 100x100
hline 50
arc 100x50 50 50 0 large
move 75x75 vline 25 arc 25x75 50 50 0
move 0x160
line 200x160 200x0 0x0
]
And here with CLOSE commands:
line-width 3
pen yellow
shape [
move 100x100
hline 50
arc 100x50 50 50 0 large
close
move 75x75 vline 25 arc 25x75 50 50 0
close
move 0x160
line 200x160 200x0 0x0
]
CURV
Smooth CURVE command shortcut.
| Arg | Type | Description | Values |
|---|---|---|---|
| point1 | [pair!] | ||
| point2 | [pair!] | ||
| point1 | [pair!] | ||
| ... | [pair!] |
Notes and Examples
From http://www.w3.org/TR/SVG11/paths.html:
"The first control point is assumed to be the reflection of the second control point on the previous command relative to the current point. (If there is no previous curve command, the first control point is the current point.)"
Simple example:
line-width 3
pen yellow
shape [
move 100x50
vline 150
curv 300x150 300x50
move 0x0
]
Same example but with relative positioning commands:
line-width 3
pen red
shape [
'move 100x50
'vline 100
'curv 200x0 200x-100
move 0x0
]
CURVE
Draws a cubic Bézier curve.
| Arg | Type | Description | Values |
|---|---|---|---|
| point1 | [pair!] | ||
| point2 | [pair!] | ||
| point3 | [pair!] | ||
| point4 | [pair!] | ||
| ... | [pair!] |
Notes and Examples
A cubic Bézier curve is defined by a start point, an end point, and two control points.
line-width 3
pen yellow
shape [
move 100x50
curve 100x150 300x150 300x50
move 0x0
]
Same example but with relative positioning commands:
line-width 3
pen red
shape [
move 100x50 'curve 0x100 200x100 200x0
move 0x0
]
HLINE
Draws a horizontal line from the current point.
| Arg | Type | Description | Values |
|---|---|---|---|
| end-x | [decimal!] |
Notes and Examples
Using absolute coordinates:
pen yellow
line-width 4
shape [
move 100x100
hline 300
move 100x150
hline 250
move 100x200
hline 200
]
Using relative coordinates:
pen red
line-width 4
shape [
move 100x100
'hline 200
'move -200x50
'hline 150
'move -150x50
'hline 100
]
LINE
Draws a line from the current point through the given points, the last of which becomes the new current point.
| Arg | Type | Description | Values |
|---|---|---|---|
| point1 | [pair!] | ||
| point2 | [pair!] | ||
| point3 | [pair!] | ||
| point4 | [pair!] | ||
| ... | [pair!] |
Notes and Examples
Using absolute coordinates:
pen yellow
line-width 4
shape [
move 50x50
line 300x120 50x120 300x50
move 0x0
]
Using relative coordinates:
pen red
line-width 4
shape [
move 50x50
move 50x50 'line 250x70 -250x0 250x-70
move 0x0
]
MOVE
Set's the starting point for a new path without drawing anything.
| Arg | Type | Description | Values |
|---|---|---|---|
| point1 | [pair!] |
Notes and Examples
The effect is as if the "pen" were lifted and moved to a new location.
Used at the end of a SHAPE command, MOVE prevents the shape from being drawn as a closed polygon.
Note: Every path defined in SHAPE block is automatically closed. To disable the auto-close feature just put at the end of the SHAPE block: move 0x0
line-width 4
pen red
shape [
move 100x100
line 20x20 150x50
move 0x0
]
pen blue
shape [
move 100x200
line 20x120 150x150
]
Using relative coordinates for the second shape:
line-width 4
pen red
shape [
move 100x100
line 20x20 150x50
move 0x0
]
pen blue
shape [
move 100x100
'move 0x100
'line -80x-80 130x30
'move 0x0
]
QCURV
Smooth QCURVE command shortcut.
| Arg | Type | Description | Values |
|---|---|---|---|
| point1 | [pair!] |
Notes and Examples
Draws a cubic Bézier curve from the current point to point1.
See: http://www.w3.org/TR/SVG11/paths.html and CURV
Using absolute coordinates:
pen yellow
line-width 4
shape [
move 0x150
qcurve 100x250 200x150
qcurv 400x150
move 0x0
]
Using relative coordinates:
pen red
line-width 4
shape [
move 0x150
'qcurve 100x100 200x0
'qcurv 200x0
move 0x0
]
QCURVE
Draws quadratic Bézier curve.
| Arg | Type | Description | Values |
|---|---|---|---|
| point1 | [pair!] | ||
| point2 | [pair!] | ||
| point3 | [pair!] | ||
| ... | [pair!] |
Notes and Examples
A quadratic Bézier curve is defined by a start point, an end point, and one control point.
Using absolute coordinates:
pen yellow
line-width 4
shape [
move 100x50
qcurve 200x150 300x50
move 0x0
]
Using relative coordinates:
pen red
line-width 4
shape [
move 100x50
'qcurve 100x100 200x0
move 0x0
]
VLINE
Draws a vertical line from the current point.
| Arg | Type | Description | Values |
|---|---|---|---|
| end-y | [decimal!] |
Notes and Examples
Using absolute coordinates:
pen yellow
line-width 4
shape [
move 100x100 vline 300
move 150x100 vline 250
move 200x100 vline 200
]
Using relative coordinates:
pen red
line-width 4
shape [
move 100x100 'vline 200
'move 50x-200 'vline 150
'move 50x-150 'vline 100
]
|
Pages |
|
|
|
Chapters
|
|





















