Skip to content

Instantly share code, notes, and snippets.

@christo
Created July 5, 2021 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christo/701ed0b11ae7654c70e8284e0b65e389 to your computer and use it in GitHub Desktop.
Save christo/701ed0b11ae7654c70e8284e0b65e389 to your computer and use it in GitHub Desktop.
var scanx = 0;
var amp;
var cy;
var cx;
function setup() {
createCanvas(800, 800);
background(100);
reset();
}
function reset() {
amp = random(15, 4 0);
cy = random(height);
cx = scanx + amp;
}
function draw() {
if (scanx > cx + amp) {
reset();
}
stroke(color(200, 0, 0));
line(scanx, 0, scanx, height);
circlePart();
scanx++;
if (scanx == width) {
scanx = 0;
background(100);
reset();
}
}
function circlePart() {
stroke(255);
var x = scanx - cx;
var dy = sqrt(amp*amp - x*x);
point(scanx, cy - dy);
point(scanx, cy + dy);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment