xxxxxxxxxx
33
function mapColors(value, min, max, colors){
let palette = colors.map(c => c.toString())
let gradient = chroma.scale(palette).mode('lab')
let mixture = map(value, min, max, 0, 1)
return gradient(mixture).hex()
}
let temp = 72
const freeze = 32
const boil = 212
function setup() {
createCanvas(200, 200);
textAlign(CENTER)
rectMode(CENTER)
noStroke()
}
function draw(){
background(255)
let tempColor = mapColors(temp, freeze, boil, 'skyblue', 'darkred')
fill(tempColor)
square(100, 100, 120)
fill(0)
text(temp, 100, 180)
temp += 1
if (temp > boil){
temp = freeze
}
}