Hi
Could you show a code example, and also describe what the example is actually displaying, and what you actually expected to be displayed?
As far as I know, there is no way to directly draw 8 bit colors on Canvas.
How are the red green blue channels given in the 8 bit color?
Wikipedia says:Bit 7 6 5 4 3 2 1 0
Data R R R G G G B B
Maybe it would be a matter of scaling those values to the RGB spectrum? Untested code:
// old is your old 8 bit color value
var oldB = old & 0x03;
var oldG = old & 0x1C;
var oldR = old & 0xE0;
/*
Scale a value from an old value range to a new value range.
see http://stackoverflow.com/a/5295202/3041008
let oldValue in [min, max]
let newValue in [a, b]
(b-a)(x - min)
f(x) = -------------- + a
max - min
*/
var oldToNew = function(x, max, b) {
return b*x/max;
};
// new is your new 24 bit color value
var newB = oldToNew(oldB, Math.pow(2, 2), Math.pow(2, 8));
var newG = oldToNew(oldG, Math.pow(2, 3), Math.pow(2, 8));
var newR = oldToNew(oldR, Math.pow(2, 3), Math.pow(2, 8));
var c = Crafty.e("2D, DOM, Color")
.color(newR, newG, newB);
Hope that helps.