You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • 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_drawImages

    And in that, you can override the palette:

    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 :)

About

Avatar for Gordon @Gordon started