class Row {
constructor({values = [], x = 0, y = 0, colLength = 20, hsla = [[225, 50, 50]], randomColor = null}) {
this.values = values;
this.x = x;
this.y = y;
this.colLength = colLength;
this.hsla = hsla;
if (randomColor) {
this.hsla = randomHsla(values.length);
}
}
showValues() {
return this.values;
}
draw(context) {
for (let i = 0; i < this.values.length; i++) {
let index = i % this.hsla.length;
context.fillStyle = `hsla(${this.hsla[index][0]}, ${this.hsla[index][1]}%, ${this.hsla[index][2]}%)`;
context.fillRect(this.x+i*(this.colLength + 5), this.y, this.colLength, 5);
}
}
move(x, y) {
this.x = x;
this.y = y;
}
coords() {
return [this.x, this.y];
}
changeColor(idx, newVals) {
this.hsla[idx] = newVals;
}
changeSaturation(idx, sat) {
this.hsla[idx][1] = sat;
return this;
}
getSaturation(idx) {
return this.hsla[idx][1];
}
}