Ahh, ok - so you can use FG/BG colors in Graphics if you just want 2 colours (even in 2 bit images), but then color 0=bg, 3=fg, and 1 and 2 are blends between.
var pal = new Uint16Array([
g.toColor("#000"),
g.toColor("#F00"),
g.toColor("#0F0"),
g.toColor("#00F")]);
g.drawImages([{
x : x, y: y,
image : img,
palette : pal
}]);
or if you want to just use drawImage, when you're using the https://www.espruino.com/Image+Converter select Image Object as the output type, then
you can set img.palette = new Uint16Array(...) as in the example above.
Ideally you want to avoid intercepting any setPixel/etc call as it'll be slow enough it'll cause you real problems :)
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Ahh, ok - so you can use FG/BG colors in Graphics if you just want 2 colours (even in 2 bit images), but then color 0=bg, 3=fg, and 1 and 2 are blends between.
You can use
g.drawImages
even with just one image: https://www.espruino.com/Reference#l_Graphics_drawImagesAnd in that, you can override the palette:
or if you want to just use drawImage, when you're using the https://www.espruino.com/Image+Converter select
Image Object
as the output type, thenyou can set
img.palette = new Uint16Array(...)
as in the example above.Ideally you want to avoid intercepting any setPixel/etc call as it'll be slow enough it'll cause you real problems :)