Animation 1

Beispiel aus dem Kapitel Processing in JavaScript.

Code

var x = -10;

function setup() {
  createCanvas(200, 200);
}

function draw() {
  background(0);
  ellipse(x, height/2, 20, 20);
  x = x + 2;
  if (x > width+10) {
    x = -10;
  }
}