Shapes¶
Every shape VeeLang can draw, with what at means for it, the properties you can give it after having, and the points and numbers you can read from a named shape (like box.center).
All shapes that have an inside take fill (the inside color), stroke (the outline color), color (both at once) and thickness (how thick the outline is). Positions are measured in steps from the top-left corner of the canvas: the first number goes across, the second goes down.
VeeLang's own words, like draw, circle, having and repeat, work in any capitals: draw, Draw and DRAW are the same word. The names you give things are different: sun and Sun are two names.
A shape's name goes after its kind, and can be joined with named or called: circle sun, circle named sun, circle called sun, or having name sun (see Naming a shape).
Every shape can also be turned and grown:
angle |
how far it is turned, clockwise: 90 is a quarter turn, 180 turns it upside down |
scale |
how big it is compared with how it was drawn: 2 is twice as big, 0.5 is half |
Every shape with an at can be placed by its middle instead, with center (see Placing by the middle).
A shape turns and grows around its center. A shape with parts (one with a { } body, or one made from a recipe) turns and grows as one piece, around the middle of all its parts. You can read angle and scale from any named shape, and its points (like box.topLeft) are where they are after turning.
draw square box at 120, 60 having size 80, fill "gold", angle 45
draw circle at box.topLeft having radius 6, fill "red"
Every shape can also be see-through, with opacity: 1 is solid (the default), 0.5 is half see-through and 0 can't be seen at all. It goes from 0 to 1. A shape you can't see can't be clicked.
Canvas paper having width 400, length 200, fill "white"
draw square at 60, 40 having size 120, fill "skyblue"
draw circle ghost at 180, 100 having radius 60, fill "tomato", opacity 0.5
draw circle at 300, 100 having radius 30, fill "green", opacity 0.2
A shape with parts is see-through as one picture: the whole face fades, and its eyes still cover its head. A part can have its own opacity too, and then it fades that much more. You can read a shape's opacity, change it like any number (ghost.opacity = 0.2), and change it slowly: ghost.opacity = 0.2 in 1 second fades it part of the way. Hiding a shape makes its opacity 0, and showing it brings back the opacity it had (see show and hide).
circle¶
draw circle at 120, 100 having radius 60, fill "tomato"
at |
the center |
| Properties | radius, fill, stroke, color, thickness |
| You can read | center, radius, color |
oval¶
draw oval at 150, 100 having width 200, length 100, fill "pink"
at |
the center |
| Properties | width, length, fill, stroke, color, thickness |
| You can read | center, width, length, color |
rectangle¶
draw rectangle at 50, 50 having width 200, length 100, fill "lightblue"
at |
the top-left corner |
| Properties | width, length, fill, stroke, color, thickness |
| You can read | center, topLeft, topRight, bottomLeft, bottomRight, width, length, color |
square¶
draw square at 50, 50 having size 120, fill "gold"
at |
the top-left corner |
| Properties | size, fill, stroke, color, thickness |
| You can read | the same as a rectangle |
triangle¶
draw triangle having corner1 at 50, 200, corner2 at 250, 200, corner3 at 150, 40, fill "green"
at |
the top-left of the box around the triangle. Without corners, a triangle is 100 wide and 100 tall. |
| Properties | corner1, corner2, corner3, fill, stroke, color, thickness |
| You can read | corner1, corner2, corner3, center, color |
polygon¶
A polygon is drawn in one of two ways.
With equal sides: say how many sides it has.
draw polygon at 150, 150 having sides 6, size 160, fill "gold"
at |
the center |
| Properties | sides (3 to 100), size (how wide it is: the corners sit on a circle that wide; 100 if not given), fill, stroke, color, thickness |
| Shape | the first corner points straight up, and the rest follow clockwise |
With corners you choose: list them.
draw polygon from 150, 20 to 230, 120 to 150, 280 to 70, 120 having fill "orange"
| Position | from the first corner to each next corner (at least 3 corners); it closes itself |
| Properties | fill, stroke, color, thickness. at (set with name.at = x, y) moves the whole polygon, like a triangle's. |
With corners from a bunch: give a bunch of places, and its places are the corners, in order. points on makes one.
circle rim at 150, 150 having radius 100
draw polygon from 5 points on rim having fill "skyblue"
Any way you draw it, you can read corner1, corner2, ... (clockwise from the top, or in the order written), center, at and color.
line¶
draw line from 50, 50 to 250, 150 having color "navy", thickness 4
| Position | from where it starts to where it ends |
| Properties | color, stroke, thickness, starthead and endhead (heads) |
| You can read | start, end, center, length, color |
lines¶
A line that turns corners: several points joined with to, drawn as one line.
draw lines hook from 50, 50 to 50, 150 to 150, 150 having endhead "arrow", thickness 8, color "navy"
Draw it as one lines and the corners are joined, even when it is thick. Several lines side by side leave a gap at each corner.
| Position | from where it starts, then a to for each point after it (at least two points) |
| Properties | color, stroke, thickness, starthead and endhead (heads), as for a line. It has no inside, so no fill |
| You can read | start, end, corner1, corner2, ... (in the order written), center and color |
A head goes at the very start or the very end, never at a corner in between. Like any other shape it can be moved, turned, made dashed or dotted, and made from a bunch of places: draw lines ring from spots.
arc¶
draw arc from 50, 150 to 250, 150 having radius 120, color "purple", thickness 4
| Position | from where it starts to where it ends |
| Which way it bends | To the left of the way it goes: from left to right it bulges up (a rainbow), from right to left it dips down (a smile) |
| Properties | radius (how round it is), curve (small or big), color, stroke, thickness, starthead and endhead (heads) |
| You can read | start, end, radius, color |
text¶
draw text at 40, 100 having content "Hello!", size 48, color "purple", font "cursive"
at |
where the words start, on the line they sit on; with a width, the top-left corner of its box |
| Properties | content (the words, in quotes), size, font ("sans-serif", "serif", "monospace" or "cursive"), color or fill, width and length (its box), align (where the words sit), editable (whether someone can type in it) |
| You can read | center (the middle of the words, or of its box), the corners (topLeft, bottomRight, …), width and length when it has a box, color |
A text with editable true can be typed into. Click or tap it, and the keyboard opens (on a tablet too). The words change as you type, and content is whatever was typed:
draw rectangle box at 40, 40 having width 320, length 60, fill "lightyellow"
draw text name at 50, 80 having content "Type your name", size 28, editable true
draw text hello at 50, 160 having size 28
forever {
hello.content = "Hello, " + name.content
wait 0.05 seconds
}
Press Enter, or click somewhere else, to finish typing. Enter also counts as pressing the enter key, so when key enter is pressed { } can hand in what was typed. Only a text can be editable, and one line at a time. name.editable = false stops it being typed into.
Words can run over several lines: press Enter inside the quotes, and each line of the code is a line in the drawing. Spaces at the start of a line are kept. The lines are 1.2 times the size apart.
draw text at 40, 60 having size 28, content "Roses are red,
Violets are blue,
I can code
And so can you!"
Give a text a width and its words wrap onto new lines to fit. It is then placed like a rectangle: at is the top-left corner of its box, and center its middle. A length makes the box taller; without one, the box is as tall as the lines. A word wider than the box sticks out of it, and lines that don't fit in the length carry on below it.
draw rectangle card at 40, 40 having width 220, length 140, fill "lightyellow"
draw text at 50, 50 having width 200, size 22, content "A long sentence wraps onto the next line by itself."
align says where the words sit, with up to two words and no quotes: one across (left, center or right) and one down (top, middle or bottom), like align bottom right. A word left out stays as it is: left and top. Down needs a length, so there's room to move the lines in. Without a box, align center and align right line the lines up with each other.
draw rectangle card at 40, 40 having width 200, length 120, fill "lightyellow"
draw text at 40, 40 having width 200, length 120, size 22, align middle center, content "Right in
the middle"
draw text at 300, 60 having size 22, align center, content "Roses are red,
Violets are blue,
I code"
Dashed and dotted outlines, and arrowheads¶
draw dashed line from 30, 40 to 330, 40
draw dotted circle at 80, 140 having radius 50, thickness 3
dashed square box at 180, 90 having size 100, color "teal"
draw box
draw line from 30, 250 to 330, 250 having endhead "arrow", thickness 2
draw arc from 30, 330 to 330, 330 having radius 200, starthead "dot", endhead "open", color "purple"
Write dashed or dotted just before a shape's type to draw its outline that way: draw dashed line …, dotted circle ring at …. It works on every shape with an outline (line, lines, arc, circle, oval, rectangle, square, triangle and polygon), and the dashes grow with thickness. A shape stays dashed or dotted for as long as it is there; to change it, draw another shape.
A line or an arc can have a head at each end: starthead for where it starts and endhead for where it ends.
| Head | What it looks like |
|---|---|
arrow |
a filled arrowhead |
open |
an arrowhead made of two short lines |
dot |
a round dot |
none |
nothing (the default) |
A head is the line's colour, grows with its thickness and points along the line, or along the curve of an arc. You can change it later, like any property: l.endhead = "arrow".
The words for a head, and an arc's curve, can be written with or without quotes. Without them, a misspelt word gets a "Did you mean…?":
draw line from 30, 50 to 330, 50 having endhead arrow, starthead dot, thickness 2
draw arc from 30, 200 to 330, 200 having curve big, endhead open
Ready-made shapes: star, heart, arrow, cross, tick, diamond¶
draw star at 70, 80 having fill "gold"
draw arrow at 190, 80 having angle 90, fill "teal"
draw cross at 70, 210 having size 80, fill "red"
draw diamond at 190, 210 having fill "skyblue"
draw heart at 310, 150 having size 120, fill "crimson"
These are recipes that come with VeeLang, written in VeeLang itself, so you use them like a recipe of your own: give them settings after having, change a setting later (s.points = 7) and they are made again, and turn, grow, move or click them like any shape. Each one is centered on its at, and takes fill, stroke, color and thickness for its outline and inside.
| Shape | Settings |
|---|---|
star |
size (from the middle to a tip; 50), points (how many tips; 5), inner (how far in the dents go, compared with the tips: 0.5 is half way; 0.5) |
heart |
size (how wide it is; 100) |
arrow |
length (100), width (how thick its shaft is; 20), head (how long its head is; 40). It points up: turn it with angle, like a clock hand, so angle 90 points right |
cross |
size (100), width (how thick its arms are; 30). Turn it with angle 45 for an x |
tick |
size (how wide and tall it is; 100), width (how thick its strokes are; 20) |
diamond |
width (60), length (100) |
A tick and a cross turned to an x mark right and wrong answers:
draw tick at 80, 100 having size 80, fill "green"
draw cross at 200, 100 having size 90, width 20, angle 45, fill "red"
If your program makes its own recipe called star, or uses star as a name for something else, your own one is used.
Points and numbers¶
A point like box.center has an x (across) and a y (down): box.center.x. Points are always positions on the whole drawing, even for a shape inside another shape.
Not yet¶
For a hexagon or a pentagon, draw a polygon with sides 6 or sides 5.