Skip to content

Animation

Everything about drawings that move: what happens first, how long things take, and the words that make shapes move, turn, grow, change, appear and disappear. Press ▶ Play on any example to watch it.

Clicking is on its own page: Clicks.


The picture, then the animation

A program runs from the top, one line after another, and each line waits for the one before it to finish.

The picture every line before the first line that takes time. It is drawn first, all at once. It is what you see before you press Play, and what a thumbnail shows.
The animation starts with the first line that takes time. From there, every line is a step that happens when its turn comes.

These lines take time, so the first one of them starts the animation:

Takes time Doesn't take time
a change, move, turn, grow, shrink, draw, show or hide with in N seconds the same lines without in N seconds
wait forever (it runs on its own, so it never holds anything up)
together { } when ... is clicked { } (it only gets ready for clicks)
play animation spin { } (it only makes an animation)
a repeat with any of these inside it a repeat without any of them
Canvas paper having width 400, length 300
draw circle sun at 200, 260 having radius 40, fill "gold"
move sun to 200, 80 in 2 seconds
sun.fill = "orange"
move sun to 200, 260 in 2 seconds

The sun starts at 200, 260, because the picture is drawn before the first move. It goes up, turns orange at the top, then goes down.

Rules:

  • A change without a time before the first line that takes time is part of the picture.
  • A change without a time after it happens at once, when its turn comes.
  • A draw after it puts the shape on the drawing when its turn comes.
  • An if after it is checked when its turn comes, using how things are then.

Tutorial: Making Things Move.


How long: in N seconds

name.property = value in N seconds
Canvas paper having width 400, length 200
draw circle ball at 60, 100 having radius 30, fill "yellow"
ball.fill = "purple" in 2 seconds
move ball by 250, 0 in 1.5 seconds
The number any number, sum or variable: in 2 seconds, in 0.5 seconds, in slow / 2 seconds
The word second or seconds, whichever reads better. Other words, like minutes, are an error: time is always in seconds.
Less than 0 an error: time only goes forwards
How it changes steadily, the same amount every moment: 100 steps in 2 seconds is 50 steps every second
Where it starts from the value the property has when the line's turn comes

What can change over time

Property Shapes How it changes
at every shape except lines and arcs moves in a straight line
x, y circle, oval, rectangle, square, polygon, text moves in a straight line
angle every shape turns
scale every shape grows or shrinks
fill, stroke, color every shape that has them the colours mix gradually
thickness every shape that has it gradually
radius circle, arc gradually
width, length oval, rectangle, square gradually
size square, text gradually
content text the old words fade out, then the new ones fade in
font text the same as content

A shape's at means what it means in Shapes: the center of a circle, the top-left corner of a rectangle.

For a shape with parts (a shape with a { } body, or one made from a recipe), at, x, y, angle and scale move, turn and grow the whole shape, parts and all. Its other properties, like fill, change only the shape itself, not its parts. A part is changed with its full name: face.eye.fill = "blue" in 1 second.


move, turn, grow and shrink

move name to x, y      move name by x, y
turn name to angle     turn name by angle
grow name to scale     grow name by amount
shrink name to scale   shrink name by amount

Each one can end with in N seconds. Without it, it happens at once.

Line Means What happens
move ball to 300, 100 ball.at = 300, 100 goes to that place
move ball by 50, 0 ball.at = where it is now, plus 50, 0 goes 50 across and 0 down from where it is
turn box to 90 box.angle = 90 turns until its angle is 90
turn box by 360 box.angle = its angle now, plus 360 turns all the way round once more
grow balloon to 2 balloon.scale = 2 twice as big as it was drawn
grow balloon by 2 balloon.scale = its scale now, times 2 twice as big as it is now
shrink balloon to 0.5 balloon.scale = 0.5 half as big as it was drawn
shrink balloon by 2 balloon.scale = its scale now, divided by 2 half as big as it is now
Canvas paper having width 400, length 300
draw square box at 60, 110 having size 80, fill "gold"
draw circle balloon at 300, 150 having radius 30, fill "red"
turn box by 360 in 2 seconds
grow balloon by 2 in 1 second
shrink balloon to 0.5 in 1 second
move balloon to 300, 40 in 1 second

Rules:

  • A shape turns and grows around its center. A triangle's or polygon's center is the middle of the box around it (a polygon drawn with sides turns around the point it was drawn around). A shape with parts turns and grows around the middle of all its parts. To turn or grow around another point, see Around a point.
  • shrink by 0 is an error: it would mean dividing by 0.
  • A line or an arc has no at, so it can only move by, not to.
  • A part (a shape inside another shape's { }) can only move by, not to.

Tutorials: Turning and Growing, Making Things Move.

Around a point

Write around and a place after turn, grow or shrink to turn or grow the shape around that place instead of its center. A door turns around its corner, and a planet goes round its sun:

Canvas paper having width 400, length 300
draw rectangle door at 60, 60 having width 40, length 100, fill "brown"
turn door by 90 around door.topLeft in 1 second
draw circle sun at 270, 150 having radius 25, fill "gold"
draw circle earth at 350, 150 having radius 10, fill "blue"
turn earth by 360 around sun.center in 4 seconds
Syntax turn name by 90 around x, y, also with to, grow, shrink and in N seconds
The place two numbers, or a place read from a shape, like sun.center or door.topLeft
What it does the shape's middle swings round the place as it turns, or moves away from it as it grows (closer as it shrinks)
Afterwards the shape has really moved: earth.center is where it is now, and a plain turn earth by 90 turns it around its own middle again
Together it adds up with other moves and turns running at the same time

The place is worked out when the line runs and stays put, so around @sun.center is a mistake.


Drawing slowly

draw ... in N seconds
Canvas paper having width 400, length 300
draw rectangle sky at 0, 0 having width 400, length 300, fill "midnightblue"
draw circle moon at 300, 80 having radius 40, fill "lightyellow" in 2 seconds
draw circle at 80, 60 having radius 4, fill "white" in 1 second

The shape fades in.

Rules:

  • The shape is part of the picture from the start, but invisible. Its name works straight away, so other lines can use moon.center.
  • A draw without a time, after the animation has started, makes the shape appear all at once when its turn comes.

show and hide

show name          hide name
show name in N seconds
hide name in N seconds
Canvas paper having width 400, length 300
draw rectangle sky at 0, 0 having width 400, length 300, fill "skyblue"
draw circle sun at 120, 100 having radius 40, fill "gold"
circle moon at 280, 100 having radius 30, fill "lightyellow"
hide sun in 2 seconds
sky.fill = "midnightblue" in 2 seconds
show moon in 2 seconds
Without a time happens at once: in the picture, if it comes before the animation starts
With a time the shape fades in or out
A shape that was made but never drawn show puts it on the drawing. After that it has been drawn, so draw moon is an error: use show and hide from then on.
A shape that's already showing (or already hidden) show (or hide) does nothing
A part use its full name: hide face.eye

Rules:

  • show and hide can go inside a shape's { } too, for its parts or for the shape itself.
  • A hidden shape can't be clicked.
  • Hiding a shape makes its opacity 0. show brings it back as see-through as it was, so a half see-through ghost comes back half see-through. Setting the opacity of a hidden shape shows it too.
Canvas paper having width 400, length 200, fill "white"
draw circle ghost at 200, 100 having radius 50, fill "slateblue", opacity 0.4
hide ghost in 1 second
show ghost in 1 second
ghost.opacity = 1 in 1 second

wait

wait N seconds
Canvas paper having width 400, length 200
draw circle frog at 60, 150 having radius 25, fill "green"
move frog by 120, 0 in 1 second
wait 2 seconds
move frog by 120, 0 in 1 second

wait does nothing for that long, then the next line carries on.


forever

forever {
  ...
}
Canvas paper having width 400, length 300
draw circle ball at 60, 150 having radius 20, fill "tomato"
draw square box at 260, 110 having size 80, fill "gold"
forever {
  turn box by 90 in 1 second
}
move ball by 0, -100 in 1 second
move ball by 0, 100 in 1 second

forever repeats the lines inside it, one after another, and never stops.

Rules:

  • forever runs on its own. It starts, and the next line carries on at once. That's why the ball moves while the box turns, and why two forevers in a row both run.
  • forever doesn't take time itself, so a forever before the first line that takes time doesn't start the animation: a change after it is still part of the picture.
  • Each time round takes at least a hundredth of a second, so a forever with no time in it never freezes the page.
  • A forever can't go inside another forever, not even by playing an animation that has one: it would start one more every time round, without end.

Tutorial: Making Things Move.


together

together {
  ...
}
Canvas paper having width 400, length 300
draw circle ball at 50, 150 having radius 20, fill "tomato"
draw square box at 300, 50 having size 50, fill "gold"
together {
  move ball by 250, 0 in 2 seconds
  turn box by 180 in 1 second
}
move ball by 0, 100 in 1 second

Every line inside together starts at the same moment.

Rules:

  • together ends when the slowest line inside it ends. Then the next line carries on.
  • A repeat inside together is one thing: it runs its own lines one after another, while the others run alongside it.
  • A forever inside together never ends, so together doesn't wait for it.
  • A shape made inside together lasts only until the end of its line, so the other lines and the lines after together can't use it. To bring in shapes together and use them later, make them before together and show them inside it:
Canvas paper having width 400, length 300
circle sun at 100, 150 having radius 40, fill "gold"
square box at 250, 110 having size 80, fill "skyblue"
together {
  show sun in 1 second
  show box in 1 second
}
move sun by 0, -60 in 1 second

Repeating with time

Canvas paper having width 400, length 300
draw circle ball at 40, 230 having radius 20, fill "tomato"
repeat 4 times {
  move ball by 40, -30 * count in 0.5 seconds
  move ball by 40, 30 * count in 0.5 seconds
}

A repeat with time inside it plays each time round, one after another. count works as always.

A repeat without time inside it, after the animation has started, happens all at once when its turn comes.


Named animations

animation name { ... }          make an animation, without playing it
play name                       play it
play animation name { ... }     make it and play it, in one go
stop name                       stop it where it is
if name is playing { ... } otherwise { ... }
Canvas paper having width 400, length 300
draw rectangle fan at 150, 140 having width 100, length 20, fill "skyblue"
animation spin {
  forever {
    turn fan by 360 in 2 seconds
  }
}
play spin
wait 3 seconds
if spin is playing {
  stop spin
}
fan.fill = "tomato"

The fan spins for 3 seconds, stops where it is, and turns red.

animation spin { } makes an animation called spin, like circle sun makes a circle without drawing it. Nothing happens yet.
play spin plays it. The next line waits for spin's own lines to finish, but not for a forever in it.
play animation spin { } makes it and plays it, like draw circle sun
stop spin stops it where it is: its lines end, and every change it started freezes. The lines after stop carry on. Stopping an animation that isn't playing does nothing.
if spin is playing { } true while spin is going, including while a forever in it runs

You can say the name like a sentence: animation called spin { } or animation named spin { }, and play animation called spin { }. They are the same as animation spin { }.

Canvas paper having width 400, length 300
draw circle ball at 50, 150 having radius 20
animation called roll {
  move ball by 300, 0 in 2 seconds
}
play animation named wiggle {
  turn ball by 360 in 1 second
}
play roll

Rules:

  • An animation needs a name of its own: a name that's already a shape, or another animation, is an error.
  • An animation has to be made before it is played: play spin above animation spin { } is an error. stop spin and if spin is playing can come before it.
  • An animation that stops itself (stop spin inside spin) skips the rest of its lines.
  • Playing an animation again (twice in a row, or on another click) starts another run beside the first. The name means the newest run, so stop spin stops only that one.

Animations with settings

An animation can take values, the way a recipe takes settings. Write them after having, each with the value it has if nobody gives one:

animation name having setting value, setting value { ... }
play name                                   uses the values it has
play name having setting value              gives some of them another value
Canvas paper having width 400, length 300
draw circle ball at 100, 250 having radius 20, fill "tomato"
animation hop having height 50, time 1, shade "tomato" {
  move ball by 0, -height in time / 2 seconds
  move ball by 0, height in time / 2 seconds
  ball.fill = shade
}
play hop
play hop having height 120
play hop having height 80, shade "gold", time 2

The ball hops three times, higher each time, and the last hop is slow and gold.

  • A setting is a number or text (words in quotes). Its value in the animation line has to be the value itself, like height 50, or a sum of numbers, like time 1 / 2. It can't be another name.
  • play hop uses every value as it is written in the animation line. play hop having height 120 changes only height; the others keep theirs. You can give them in any order.
  • The values you give can be worked out: play hop having height n * 10.
  • A setting is used in the lines of its animation, and nowhere else. It keeps the value it was played with, so the animation can't change it.
  • The animation can still use the drawing's shapes and variables, like any other animation.
  • Each play is a run of its own with its own values. Two plays at the same time, in a together, don't mix up their values. stop hop stops the newest run, as before.
  • An animation with settings is made at the top of your code, not inside a { }.

What VeeLang says when something is wrong:

What you write What VeeLang says
play hop having hieght 5 'hop' has no setting called 'hieght'. Did you mean 'height'?
play hop having height "tall" 'height' is a number, so it needs a number, but this is text.
play hop having height 5, height 6 'height' is given twice.
play spin having speed 3, where spin has no settings 'spin' doesn't take any values.
animation hop having height 3, height 4 { } The setting 'height' is listed twice.
animation hop having ball 3 { }, where ball is a shape 'ball' is already the name of something in your drawing.
play hop having height 'height' needs a value.
animation hop(height) { } or play hop(30) An animation doesn't use ( ). Write animation hop having height 30 { } and play hop having height 30.
draw circle ball at 100, 100
animation hop having height 50 {
  move ball by 0, -height in 1 second
}
play hop having hieght 80

Tutorial: Click to Make Things Happen.


Drawing again and again

A draw inside a forever, a repeat that takes time, or a click draws a new shape each time it runs.

Canvas paper having width 400, length 300
draw rectangle at 0, 250 having width 400, length 50, fill "forestgreen"
repeat 5 times {
  draw circle flower at 70 * count, 240 having radius 6, fill "pink" {
    circle at 0, 0 having radius count, fill "gold"
  }
  grow flower by 3 in 1 second
}

Each time round draws a new flower. grow flower grows the one just drawn and leaves the others as they are.

Rules:

  • Each run makes its own shape. Its name means that run's copy, and only lasts for that run.
  • The shape's properties, its parts' numbers, and a line's or polygon's points can all use values that only that run knows, like count, or where another shape is right then.
  • The name must be a new one. Drawing a shape made outside (draw ball inside a forever) is an error: use show instead.
  • A shape drawn there can't be used by name outside it.

Variables in the animation

Canvas paper having width 400, length 200
draw circle ball at 30, 100 having radius 15, fill "tomato"
speed = 10
forever {
  move ball by speed, 0 in 1 second
  speed = speed + 10
}

The ball goes a little faster every second.

Rules:

  • A variable change is a step too: it happens when its turn comes, and the lines after it use the new value.
  • A variable changed in a forever, a click, a named animation, a together or a repeat that takes time is read each time a line uses it. So a click can change what a forever does.
  • A variable changed there has to be made at the top first, like speed = 10.

Tutorial: Remembering Things.


Following with @

Canvas paper having width 400, length 300
draw circle kite at 300, 60 having radius 15, fill "tomato"
draw line string from 60, 280 to @kite.center
forever {
  move kite by -150, 30 in 2 seconds
  move kite by 150, -30 in 2 seconds
}

kite.center is where the kite is right now. @kite.center follows it: wherever the kite goes, the end of the string goes too.

Line What happens
draw circle moon at sun.center the moon goes where the sun is now, and stays there
draw circle moon at @sun.center the moon follows the sun, wherever it goes
moon.at = @cloud.center the moon starts following the cloud instead
move moon by 50, 0 or moon.at = 10, 10 the moon stops following and goes somewhere of its own
move moon to @sun.center in 2 seconds the moon chases the sun for 2 seconds, then keeps following it

Rules:

  • @ follows just the property after it: in at @bee.x + 10, 260, the + 10 and the 260 stay as they are.
  • Any property can be followed, not just places: fill @sun.fill keeps the same colour as the sun.
  • @ goes in a shape's properties (at, having, a line's from and to) and in a change. Not in a variable: x = @sun.x is an error.
  • Shapes can't follow each other round in a circle: if b follows a, a can't follow b.
  • A part can't follow a shape outside its own shape (it goes wherever its shape goes), but it can follow another part of its own shape.

Tutorial: Making Things Move.


Recipes in the animation

A shape made from a recipe changes through its settings, and a setting can change over time:

Canvas paper having width 400, length 300
shape face having size 60, skin "gold" {
  circle head having radius size / 2, fill skin
  circle eye1 at -size / 6, -size / 10 having radius size / 15, fill "black"
  circle eye2 at size / 6, -size / 10 having radius size / 15, fill "black"
}
draw face sam at 200, 150
sam.size = 160 in 2 seconds
sam.skin = "pink" in 2 seconds

Rules:

  • The recipe makes the shape again as the setting changes, so its parts change with it.
  • A number setting changes gradually, and a colour mixes gradually. Words that aren't colours, like hair "curly", change when the time is up.
  • A setting can follow, like size @sun.radius * 4.
  • A recipe's parts can't be changed from outside (sam.eye1.fill = "blue" is an error). Change its settings instead.
  • at, angle and scale move, turn and grow the whole shape, as for any shape with parts.

Not yet

These are errors for now:

What you write What VeeLang says
p.sides = 8 or p.size = 80 on a polygon, with a time or after the animation has started Changing 'sides' over time isn't something I can do in an animation yet. (Without a time: Changing 'sides' isn't something I can do in an animation yet.)
t.corner1 = 30, 30 on a triangle, with a time or after the animation has started Changing 'corner1' over time isn't something I can do in an animation yet.
a.curve = "big" or a.startangle = 30 on an arc, with a time or after the animation has started Changing 'curve' over time isn't something I can do in an animation yet.
move face.eye to 50, 50 (a part, to a place) Moving a part to a place isn't something I can do in an animation yet.
move l to 50, 50 (a line or an arc, to a place) A line doesn't have an 'at', so I don't know which point to move to that place.
paper.fill = "navy" (the canvas), with a time or after the animation has started 'paper' isn't a shape, so it can't move or change.
circle dot at 50, 50 (making a shape without drawing it) inside a forever, a click or another block that takes time While things move I can draw and change shapes, wait and repeat, but I can't make a shape without drawing it, or other names, yet.
stop moon or if moon is playing, where moon is a shape drawn in 2 seconds 'moon' isn't an animation. 'stop' is for animations, made with 'animation'.
animation spin { }, play spin or stop spin inside a shape's { } 'animation', 'play' and 'stop' go outside a shape's { }: they belong to the whole drawing.
draw polygon p at 150, 150 having sides 5, size 100, fill "gold"
p.sides = 8 in 2 seconds