xxxxxxxxxx
74
let rectWidth = 8;
let rectHeight = 320;
let patternValue = 100000;
let yLoc0, yLoc1;
function setup() {
createCanvas(640, 640);
yLoc0= height *.25
yLoc1= height * .75
// for loop example
for (let i = 0; i < 10; i++) {
print(i);
}
// while loop example
let num = 40;
while (num < 50) {
print(num);
num++;
}
rectMode(CENTER);
}
function draw() {
// if(frameCount%20 ==0) {patternValue= random(1000000);
// }
// randomSeed(patternValue);
// background(100);
// fill(random(0,255),random(0,255),random (0,255));
// loop through and draw rectangles on screen
// offset the start of the draw by half the width of the rect
// since we're drawing with rectmode center
for (let i = rectWidth / 2; i < width; i += rectWidth) {
let noiseValue= noise(frameCount * 0.01,i *.001);
let scaledNoise= ( noiseValue - 0.5) * 100;
rect(i, yLoc0 + scaledNoise, rectWidth, rectHeight);
}
for (let i = rectWidth / 2; i < width; i += rectWidth) {
let noiseValue= noise(frameCount * 0.01,i *.001);
let angle= ( noiseValue) * TWO_PI;
push();
translate (i,yLoc1);
rotate(angle)
rect(0, 0, rectWidth, rectHeight);
pop();
}
// for (let i = rectWidth / 2; i < width; i += rectWidth) {
// rect(i, yLoc1 + random(-20, 20), rectWidth, rectHeight);
// }
}
function mousePressed(){
patternValue = random(1000000);
}
function keyPressed(){
if (key=='a') {
patternValue = 1000;
}
if (key=='b') {
patternValue = 10000;
}
}