Positions and Parts¶
Where shapes go, how to name them, how to change, copy and move them, how to build a shape out of parts, and how to make one shape follow another.
The grid¶
draw circle at 0, 0 having radius 20, fill "red"
draw circle at 200, 100 having radius 20, fill "blue"
| A position | two numbers: how far across (x), then how far down (y) |
0, 0 |
the top-left corner of the canvas |
Bigger x |
further right |
Bigger y |
further down |
| Negative numbers | left of, or above, where you measure from |
No at |
a shape that needs a place and has none is drawn at 0, 0 |
A position can also be written in brackets, as (200, 100). It means exactly the same, wherever a position goes:
draw circle at (0, 0) having radius 20, fill "red"
draw circle at (200, 100) having radius 20, fill "blue"
draw line from (0, 0) to (200, 100)
The canvas is 800 across and 600 down unless you choose another size (see Canvas and Layers).
Learn it step by step: Circle Deep Dive
What at means¶
at is a different point on each kind of shape:
| Shape | at is |
|---|---|
circle, oval |
the center |
rectangle, square |
the top-left corner |
polygon with sides |
the center |
triangle |
the top-left of the box around the triangle |
text |
where the words start, on the line they sit on |
line, arc |
no at: they use from and to |
draw circle at 100, 100 having radius 40, fill "gold"
draw square at 100, 100 having size 80, fill "skyblue"
draw circle at 100, 100 having radius 4, fill "red"
The red dot marks 100, 100: the circle's center and the square's top-left corner.
Learn it step by step: Rectangle Deep Dive
Placing by the middle: center¶
draw square box at 60, 40 having size 120, fill "lightyellow"
draw text label having center box.center, content "E", size 60
draw rectangle bar having center 300, 100, width 40, length 20, fill "skyblue"
bar.width = 160
| Syntax | having center 300, 100, or name.center = 300, 100 |
| Worked-out numbers | write at first, like a corner: having center at x + 10, y |
| What it does | puts the middle of the shape there, instead of its at |
| Afterwards | the middle stays there: the bar above grows on both sides, and new words stay centered |
move name to |
puts the middle there too |
| Shapes that have it | every shape that has an at: circle, oval, rectangle, square, triangle, polygon, text |
Words placed by their middle are centered exactly, however wide their letters are, so a letter sits in the middle of its box.
Reading points: box.center¶
draw rectangle box at 100, 60 having width 160, length 80, fill "lightblue"
draw circle at box.center having radius 6, fill "red"
draw circle at box.topRight having radius 6, fill "green"
draw line from box.topLeft to box.bottomRight
| Syntax | name.point, like box.center or box.topLeft |
| Which points | each shape has its own list: see Shapes |
name.at |
the shape's at point |
| One number from a point | add .x or .y: box.center.x, box.topLeft.y |
| Numbers | name.radius, name.width and the like can be used in sums: c.x + c.radius |
A point is always a place on the whole drawing, even for a shape inside another shape, and even after the shape is turned.
Learn it step by step: Shape Naming
x and y¶
draw circle ball at 60, 100 having radius 30, fill "red"
ball.x = 250
draw circle at ball.x, ball.y + 50 having radius 10, fill "gray"
name.x |
how far across the shape's at is |
name.y |
how far down the shape's at is |
| Shapes that have them | circle, oval, rectangle, square, polygon with sides, text |
| Shapes that don't | triangle, line, arc (use name.at = ... or move instead) |
ball.at.x reads the same number as ball.x. To change just one direction, write ball.x = ...; ball.at.x = ... is a mistake.
Learn it step by step: Changing, Copying and Moving Shapes
Measuring from other shapes¶
draw circle head at 150, 80 having radius 30, fill "white", stroke "black"
draw circle body at head.x, head.y + 70 having radius 40, fill "white", stroke "black"
draw circle at body.center having radius 4, fill "black"
| Syntax | use a point or number of a named shape wherever a number or point goes |
| When it's read | once, on that line. If head moves later, body stays where it was put. |
| Order | make the shape you read from on an earlier line |
To keep up with a shape that moves later, follow it with @ (see Following with @).
Learn it step by step: Shape Naming
Points round a shape: points on¶
12 points on rim is a bunch of 12 places spread evenly round the shape called rim, like the numbers on a clock.
circle rim at 200, 150 having radius 100
draw rim
repeat for each p in 12 points on rim {
draw circle at p having radius 6, fill "navy"
}
- The first place is at 12 o'clock, straight up from the middle of the shape, and the rest go clockwise. If the shape is turned, so are its places.
- They are spread evenly along the outline, so on a square or an oval the gaps along the edge are all the same.
- On a line or an arc they go from one end to the other, with both ends included.
- They work on circles, ovals, squares, rectangles, triangles, polygons, lines and arcs. A shape that's hidden, or made without
draw, still gives its places, so it can be a guide you never see. bunch spots = 12 points on rimkeeps the places in a bunch:spots[1]is the first one. In a list, eachpoints onputs in its places one by one, sobunch b = 4 points on c, 2 points on dhas 6 places, andadd 3 points on d to badds 3 more.- The places are where the shape was when that line ran. If the shape moves afterwards, they stay where they were, unless you follow one with
@(below). Inside a recipe this doesn't matter, because changing a recipe's setting makes its parts again.
Here is a star made from two circles: tips on a big one, dents on a small one turned half a step, and a polygon through them all.
shape mystar having size 80, tips 5 {
circle outer at 0, 0 having radius size
circle middle at 0, 0 having radius size / 2, angle 180 / tips
hide outer
hide middle
bunch out = tips points on outer
bunch dents = tips points on middle
bunch corners
repeat tips times {
add out[count] to corners
add dents[count] to corners
}
polygon edge from corners having fill "gold"
}
draw mystar s at 200, 150 having tips 6
Following a place: @spots[3]¶
Put @ in front of a place from points on and it keeps its spot on the shape as the shape moves, turns or grows, the way @sun.center follows a shape's middle:
draw circle ball at 100, 100 having radius 30, fill "skyblue"
bunch spots = 8 points on ball
draw circle dot at @spots[3] having radius 5, fill "red"
draw line pin from @spots[1] to @spots[5] having thickness 3
move ball by 120, 0 in 2 seconds
grow ball by 20 in 2 seconds
- Which place it is (
3) is worked out when the line runs. Only where that place is on the shape follows. - It goes where a property goes, like
ator a line'sfromandto. Anywhere else,@is a mistake (vee.follow.notHere). - Only places from
points onfollow. A place made another way, likeball.centerkept in a bunch, stays where it was.
Naming a shape, drawing it later¶
circle sun at 200, 100 having radius 50, fill "gold"
sun.fill = "orange"
draw sun
| Make and draw | draw circle sun at ... |
| Make now, draw later | circle sun at ..., then draw sun |
| A shape that is never drawn | is not in the picture, but you can still read from it and copy it |
| Names | each shape needs its own name; two shapes called sun is a mistake |
| One draw | a shape can be drawn only once. For two, copy it. To move it, change its at. |
draw circle c at 100, 100 having radius 30
draw c
Four ways to write a name¶
These four lines make the same circle:
draw circle sun at 100, 100 having radius 30
draw circle named moon at 200, 100 having radius 30
draw circle called star at 300, 100 having radius 30
draw circle at 400, 100 having name comet, radius 30
circle sun |
the name straight after the kind of shape |
circle named sun, circle called sun |
the same, written like a sentence |
having name sun |
the name as one of the settings, anywhere in the list: having radius 30, name sun |
| Everywhere | all four work with draw, with a shape you draw later (circle named sun at 100, 100, then draw sun), with the parts inside a { } body, with polygon, line and arc, and with the shapes your recipes make. (having name is for shapes only: animations and bunches use named or called) |
| No quotes | a name is a word. name "sun" is a mistake: write name sun |
| Named once | a shape keeps the name it is given. A second name (circle named sun having name moon), or sun.name = moon, is a mistake |
Recipes with a name setting |
if your recipe has a setting called name, then having name is that setting, so give the shape its name with draw pet called rex |
named and called |
VeeLang's own words, so they can't be names. circle named with no name after it is a mistake, and so is draw circle named at 10, 10 |
| Animations and bunches | the same words work there: animation called spin { }, play animation named spin { }, bunch called garden |
A shape made without drawing it, and a part of a body:
circle named sun at 100, 100 having radius 30
draw sun
shape face having size 100 {
circle called head at 0, 0 having radius size / 2
circle at 0, -10 having name nose, radius 5
}
draw face called kim at 300, 150
draw circle at 100, 100 having name "sun"
draw circle named sun at 100, 100 having name moon
Learn it step by step: Shape Naming
Changing a shape¶
circle ball at 150, 150 having radius 40
ball.fill = "orange"
ball.radius = 70
ball.at = 200, 150
draw ball
| Syntax | name.property = value |
| What you can change | any property the shape can have after having, plus at, x and y where it has them (see Shapes) |
| Moving | name.at = x, y, or move name by 10, 0 (that far from where it is), or move name to x, y |
| Turning and growing | name.angle = 45 or turn name by 45; name.scale = 2 or grow name by 2 |
| After drawing | the picture shows each shape as it is at the end of the program, so a change after draw still shows |
A line or an arc has no at to change: move it with move.
draw line stick from 20, 20 to 120, 60 having thickness 4
move stick by 100, 50
Learn it step by step: Changing, Copying and Moving Shapes
Copying a shape¶
circle first at 80, 100 having radius 40, fill "gold"
circle second = first
second.x = 200
second.fill = "pink"
draw first
draw second
| Syntax | kind newName = oldName, like circle second = first |
| The kind | must match: copying a circle into a square is a mistake |
| What's copied | everything the shape has at that moment, including its parts |
| Afterwards | the copy is its own shape. Changing one doesn't change the other. |
| Drawing | a copy isn't drawn until you draw it, even if the original was |
A copy starts in the same place as the original, so move it, or it sits right on top.
Learn it step by step: Changing, Copying and Moving Shapes
Shapes with a body: parts¶
draw circle face at 200, 150 having radius 100, fill "gold" {
circle eye at -35, -25 having radius 12, fill "white"
circle pupil at eye.center having radius 5, fill "black"
arc from 50, 30 to -50, 30 having radius 60, thickness 6
}
| Syntax | a shape, then its parts inside { } |
| Which shapes | circle, oval, rectangle, square, text, triangle and a polygon with sides (a line, an arc or a polygon given by its corners can't have a body) |
draw |
not written for parts. Drawing the shape draws its parts, on top of it, in the order written. |
| Parts' numbers | measured from the shape's at: from a circle's center, from a rectangle's top-left corner, from the top-left of the box around a triangle |
| Names inside | parts use each other's names without a dot: eye.center |
| Reading from inside | a point of the shape itself (face.center) or of any of its parts, at any depth, stays measured from the shape, so it moves with the shape |
| Reading from outside | a point of any other shape is a place on the drawing, so that part stays put when the shape moves |
| Parts inside parts | allowed, as deep as you like; each is measured from the shape it's in |
Learn it step by step: Shapes Inside Shapes
Full names: face.eye¶
draw rectangle house at 80, 120 having width 240, length 160, fill "wheat" {
rectangle door at 100, 80 having width 40, length 80, fill "saddlebrown" {
circle knob at 32, 40 having radius 4, fill "gray"
}
}
house.door.knob.fill = "gold"
draw circle at house.door.knob.center having radius 2, fill "black"
| Syntax | shape.part, and shape.part.part for deeper parts |
| Outside the body | a part's own name alone isn't known: write house.door, not door |
| Same part names | different shapes can each have a part called eye |
| Changing a part | allowed for a shape with a body: face.eye.fill = "blue", face.eye.at = 10, 0 |
| Moving a part | its new numbers are still measured from the shape it's in |
A shape made from a recipe is different: only its settings change it, so changing one of its parts from outside is a mistake (vee.recipe.partChange):
shape face {
circle eye at 10, 10 having radius 5
}
draw face sam at 100, 100
sam.eye.fill = "blue"
Learn it step by step: Shapes Inside Shapes, and Shapes Made of Parts for bodies and recipes side by side.
Moving, turning and growing as one piece¶
draw circle face at 150, 120 having radius 60, fill "gold" {
circle eye at -20, -15 having radius 8, fill "black"
circle eye2 at 20, -15 having radius 8, fill "black"
}
face.at = 250, 150
face.angle = 30
face.scale = 1.5
draw circle at face.eye.center having radius 3, fill "red"
| Moving | changing the shape's at, or move, moves all its parts with it |
| Turning and growing | angle and scale turn and grow the shape and all its parts as one piece, around the middle of all its parts |
| Points after turning | face.eye.center is where the eye is now, after the turn |
| Copies | copying a shape copies its parts; the copy's parts are its own |
Learn it step by step: Turning and Growing
Following with @¶
draw circle kite at 300, 60 having radius 15, fill "tomato"
draw line string from 60, 280 to @kite.center
draw oval shadow at @kite.x + 10, 290 having width 20, length 6, fill "gray"
kite.at = 200, 100
Plain name: kite.center |
read once, where it's written |
With @: @kite.center |
followed: whenever the kite changes, so does the string |
| What can be followed | any property: places (@kite.center, @kite.x), numbers (@kite.radius), colors (fill @kite.fill) |
| Sums | only the part after @ is followed: in @kite.x + 10, 290, the + 10 and the 290 stay as they are |
| Where | in having, after at, from or to, and after = (shadow.at = @cloud.center) |
| Stopping | giving the property a value of its own (shadow.at = 100, 100, move shadow by 0, 10) stops it following |
| Not in a circle | two shapes can't follow each other, and a shape can't follow itself (vee.follow.circle) |
Learn it step by step: Making Things Move: Following Another Shape
Parts that follow¶
draw circle face at 150, 100 having radius 60, fill "gold" {
circle p0 at -20, 0 having radius 5, fill "black"
circle p1 at 20, 0 having radius 5, fill "black"
line from 0, 40 to @p0.center
line from 0, 40 to @p1.center
}
face.p1.at = 30, -30
| A shape on its own | may follow any shape, or any part of one (@face.eye.center) |
| A part | may follow only its own shape, or other parts of the same outermost shape (vee.follow.part) |
draw circle sun at 50, 50 having radius 10
draw circle face at 200, 150 having radius 100 {
line from 0, 0 to @sun.center
}
Learn it step by step: Making Things Move: Following Another Shape