xxxxxxxxxx
37
function fadeColor(str, alpha=1.0){
let c = color(str)
c.setAlpha(alpha * 255)
return c
}
let temp = 72
const freeze = 32
const boil = 212
function setup() {
createCanvas(200, 200);
textAlign(CENTER)
rectMode(CENTER)
noStroke()
}
function draw(){
background(255)
fill(80)
square(50, 50, 100)
square(150, 150, 100)
let circleAlpha = map(temp, freeze, boil, 0.0, 1.0)
let circleColor = fadeColor('lightskyblue', circleAlpha)
fill(circleColor)
circle(100, 100, 120)
fill(0)
text(temp, 15, 190)
temp += 2
if (temp > boil){
temp = freeze
}
}