xxxxxxxxxx
36
/*
Based on Alexander Miller’s video on Recreating Vintage Computer Art with Processing, an excellent introduction to creative coding with parametric equations and inspired by John Whitney's work:
https://www.youtube.com/watch?v=LaarVR1AOvs&t=181s
*/
let t = 1;
function setup() {
createCanvas(windowWidth, windowHeight);
strokeWeight(2);
stroke(255);
}
function draw() {
background(0, 20);
translate(width / 2, height / 2);
let amplitude = width/3; //controls how much of the screen the design takes up
//these variables control where the design takes place across the screen and how much of the screen the design covers
//alternates between sine and cosine to give the design a sense of randomness instead of going back and forth between points how the wave usually works
let x1 = amplitude + cos(t / 10); //allows the first x of the line to move across the width of the screen within the equation
let y1 = amplitude * sin(t / 10); //allows the first y of the line to move across the height of the screen within the equation
let x2 = (amplitude * 2) * cos(t / 20); //allows the second x of the line to move across the width of the screen within the equation
let y2 = (amplitude * 2) * cos(t / 10); //allows the second y of the line to move across the height of the screen within the equation
line(x1, y1, x2, y2); //draws the line based on the x and y points determined above
t++;
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
background(0);
}