xxxxxxxxxx
38
function setup() {
createCanvas(windowWidth, windowHeight);
colorMode(HSB, 360, 100, 100);
noStroke();
}
function draw() {
background(220);
// Draw 10 swatches
for (let col = 0; col < 10; col++) {
// Calculate brightness linearly
// Each swatch is 10% brighter
let b = col*10;
// Calculate x-position of swatch
let x = col * width / 10;
// Draw the swatch
fill(0, 0, b);
rect(x, 0, width / 10, height/2);
}
// Draw 10 swatches
for (let col = 0; col < 10; col++) {
// Calculate brightness exponentially
// where is this from??
let b = pow(2, (col/2+2));
// below, actual exponential interpolation
// doesn't look good
// let b = pow(91, (col/9)) - 1;
// Calculate x-position of swatch
let x = col * width / 10;
// Draw the swatch
fill(0, 0, b);
rect(x, height/2, width / 10, height);
}
}