Skip to content

Canvas Class

moononournation edited this page Mar 11, 2021 · 3 revisions

Arduino_GFX provide various canvas class as a buffer for complicated drawing and flush to real display after draw finished.

First declare a canvas output display:

Arduino_DataBus *bus = create_default_Arduino_DataBus();
Arduino_GFX *output_display = new Arduino_ST7789(bus, TFT_RST, 0 /* rotation */, true /* IPS */);

16-bit color Canvas (240x320 resolution only works for ESP32 with PSRAM)

Arduino_GFX *gfx = new Arduino_Canvas(240 /* width */, 320 /* height */, output_display);

Indexed color Canvas, mask_level: 0-2, larger mask level mean less color variation but can have faster index mapping

Arduino_GFX *gfx = new Arduino_Canvas_Indexed(240 /* width */, 320 /* height */, output_display,
    0 /* output_x */, 0 /* output_y */, MAXMASKLEVEL /* mask_level */);

3-bit color Canvas, R1G1B1, 8 colors

Arduino_GFX *gfx = new Arduino_Canvas_3bit(240 /* width */, 320 /* height */, output_display,
    0 /* output_x */, 0 /* output_y */);

Mono color Canvas

Arduino_GFX *gfx = new Arduino_Canvas_Mono(240 /* width */, 320 /* height */, output_display,
    0 /* output_x */, 0 /* output_y */);
Clone this wiki locally