I want to make a grid of squares which will be adjustable from two sliders, one for the width and the other for the height. I've managed somehow to make it work for the width of the grid but I have no luck for the height.
Below is the code:
let bubbles = [];
var slider, slider2 ;
function setup() {
var canvas=createCanvas(windowWidth, windowHeight);
slider = createSlider (10,260,260);
slider2 = createSlider (10,260,260);
for (var i=0; i<25; i++) {
for ( var j=0; j<5; j++){
var x = i * 260;
var y=j*260;
let b = new Bubble(x, y);
bubbles.push(b);
}
}
}
function draw() {
background(0);
var value = slider.value();
for (let i = 0; i < bubbles.length; i++) {
bubbles[i].show(i);
}
}
class Bubble {
constructor(x, y) {
this.x = x;
this.y = y;
this.brightness = (0);
this.slider=slider.value();
this.slider2=slider2.value();
}
show(i) {
push();
stroke(255);
//noStroke ;
strokeWeight(0.2);
fill(this.brightness);
this.x=((i/5) - ((i%5)/5) ) * slider.value();
//this.y=((i/5) - ((i%5)/5) ) * slider2.value();
translate(this.x, this.y);
rect(0 ,0,260);
pop();
}
}