Lissajous scanner
It's apparently possible to draw a Lissajous curve row by row!
function setup() {
createCanvas(450, 450);
noSmooth()
background(220);
}
let a = 3, b = 3, x = 0, d = 0
function draw() {
x += 2
if (x > 400) {
x = 0
a = round(random(1, 10))
b = round(random(1, 10))
d = round(random(1, 4))
print(a, b, d)
}
translate(25, 25)
if (d == 1) {
applyMatrix(0, 1, 1, 0, 0, 0)
} else if (d == 2) {
applyMatrix(-1, 0, 0, 1, 400, 0)
} else if (d == 3) {
applyMatrix(0, -1, 1, 0, 0, 400)
}
stroke(220)
strokeWeight(2)
line(x, 0, x, 400)
stroke(0)
let t = (asin((x - 200) / 200)) * a
for(let i = 0; i < b * 2; i ++) {
point(x, 200+sin((t+PI * i) / b)*200)
}
}(Originally seen at https://editor.p5js.org/bojidar-bg/sketches/ti72J47-7)
Browse more articles?
← Gear face Experiments tagged p5 (40/85) Checkerboard animation 1 →
← Gear face Experiments on this site (40/85) Checkerboard animation 1 →