{
let dc,canvas;
let height=900
let width=900
if (this) canvas=this,dc = canvas.getContext("2d");
else {
dc = DOM.context2d(width, height);
canvas = dc.canvas;
dc.fillStyle = '#000';
dc.fillRect(0, 0, width, height);
}
dc.fillStyle = '#000';
dc.fillRect(0, 0, width, height);
let dropHeight = height / stages.length
for( let t=0; t<stages.length; t++) {
var pool = stages[t].liquid
let poolSize = pool.length
var totalHeat = stages[t].totalHeat
var dropWidth= Math.floor( width / (pool.length-1) )
console.log(width, dropWidth)
for( let drop=0; drop<poolSize; drop++ ) {
let droplet = pool[drop] * totalHeat
let alpha = droplet
let average = 1/pool.length * totalHeat
let r = droplet < average ? 255 *droplet : 0
let g = droplet > average ? 255 *droplet : 0
let b = droplet>.99 ? 255 : 0
dc.fillStyle = `rgba(${r},${g},${b}, ${alpha})`
let x = drop*dropWidth
let y = dropHeight*t
dc.fillRect( x,y,
dropWidth,dropHeight)
}
}
yield canvas
}