I found this fantastic HTML5 fire animation online [credit: iBasskung on YouTube] and I'm trying to figure out how to make the black background transparent. I'm an intermediate JS coder but it seems like the background is part of the fire and needs an opacity of 0.
I've examined the color array and flame renderer, but I don't see any hex or rgba values anywhere.
Thoughts on how to extricate the black bg from the flames themselves?
// color array
for (i = 0; i < 32; ++i) {
colors[i][2] = i << 1;
colors[i + 32][0] = i << 3;
colors[i + 32][2] = 64 - (i << 1);
colors[i + 64][0] = 255;
colors[i + 64][1] = i << 3;
colors[i + 96][0] = 255;
colors[i + 96][1] = 255;
colors[i + 96][2] = i << 2;
colors[i + 128][0] = 255;
colors[i + 128][1] = 255;
colors[i + 128][2] = 64 + (i << 2);
colors[i + 160][0] = 255;
colors[i + 160][1] = 255;
colors[i + 160][2] = 128 + (i << 2);
colors[i + 192][0] = 255;
colors[i + 192][1] = 255;
colors[i + 192][2] = 192 + i;
colors[i + 224][0] = 255;
colors[i + 224][1] = 255;
colors[i + 224][2] = 224 + i;
}
// render the flames
for (let y = skipRows; y < canvasHeight; ++y) {
for (x = 0; x < canvasWidth; ++x) {
index = y * canvasWidth * 4 + x * 4;
let value = fire[(y - skipRows) * canvasWidth + x];
data[index] = colors[value][0];
data[++index] = colors[value][1];
data[++index] = colors[value][2];
data[++index] = 255;
}
}