Example: Wandering Point

Published

September 24, 2026


let position;
let hue = 180;

function setup() {
  createCanvas(600, 600);
  position = createVector(width / 2, height / 2);
  strokeWeight(25);
  colorMode(HSB, 360, 100, 100, 100);
  stroke(0, 3);
  background("white");

}

function draw() {
  //    background("white");
  stroke(hue, 100, 100, 10);
  point(position.x, position.y);
  position.x = max(0, min(position.x + random(-3, 3), width));
  position.y = max(0, min(position.y + random(-3, 3), height));

  hue = (hue + 360 + random(-5, 5)) % 360;
}