Running square
Run, square, run!
function setup() {
createCanvas(400, 400);
angleMode(DEGREES)
}
function draw() {
background(255);
push()
stroke(0, 50)
translate(cos(frameCount * 0.12) * 20, 0)
line(100, 200, 300, 200)
translate(cos(frameCount * 0.23) * 20, 0)
line(100, 200, 300, 200)
translate(cos(frameCount * 0.41) * 20, 0)
line(100, 200, 300, 200)
pop()
push()
stroke(0, 150)
fill(255)
translate(sin(frameCount) * 10, 0)
translate(245 - frameCount / 90 % 1 * 50, 200)
rotate(frameCount % 90 + 180)
square(0, 0, 50)
pop()
}(Originally seen at https://editor.p5js.org/bojidar-bg/sketches/Gdosvicho and https://mastodon.social/@bojidar_bg/113873947198136419)
Browse more articles?
← Wall of eyes Experiments tagged p5 (21/85) Spinning squares →
|← Experiments tagged critter (1/6) Glitch butterfly →
← Wall of eyes Experiments on this site (21/85) Spinning squares →