xxxxxxxxxx
// Exercise 4: Briski
// This code uses 3 arrays that are randomly assigned every time you start it
// I wanted to practice using multiple arrays at once
// You can also click the mouse to activate the stroke on the rectangles
// This is randomly assigned at the beginning, then activated when clicked
let rNum = new Array(90);
let rColour = new Array(256);
let rStroke = new Array (256);
function setup() {
createCanvas(1000, 1000);
loop();
colorMode(HSB);
for (let i = 0; i< rNum.length; i++) {
rNum[i] = random (1, 1000);
}
for (let i = 0; i< rColour.length; i++) {
rColour[i] = random (255);
}
for (let i = 0; i < rStroke.length; i++) {
rStroke[i] = random (1, 255);
}
}
function draw() {
background('slategrey');
for (let i = 0; i< rNum.length; i++) {
let x = map (i, 0, 3, 0, 100);
let y = 0;
let diameter = dist(x, y, mouseX, mouseY);
rect (x, y, diameter, diameter);
fill (rColour[i], rColour[i], rColour[i]);
}
}
function mousePressed() {
for (let i = 0; i< rStroke.length; i++)
stroke(rStroke[i]);
strokeWeight (10);
}