xxxxxxxxxx
57
let rectWidth = 8;
let rectHeight = 100;
let patternValue = 100000;
let yLoc0, yLoc1;
function setup() {
createCanvas(640, 640);
// yLoc0=height*.25;
// 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);
// }
// background(255);
randomSeed(patternValue);
background(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 = i + rectWidth) {
//rect(i, height / 2 + random(-20, 20), rectWidth, rectHeight);
let noiseValue = noise(frameCount*0.01, i += rectWidth);
let scaleNoise = (noiseValue - 0.5)*100;
rect(i, yLoc0+noiseValue, rectWidth, rectHeight);
}
function mousePressed() {
patternValue = random(1000000);
}
}
function keyPressed(){
if (key == 'a')
patternValue = random(1000000);
}
// if (key=='b'){
// patternValue = 10000;
// }