Skip to main content

Graphics

The @devicescript/graphics package provides an Image type and a Display type that supports paletted graphics.

Progress bar image

The image can be used to author efficient driver for small screens such as the SSD1306 OLED screen

import { Image } from "@devicescript/graphics"

const img = Image.alloc(128, 64, 1)

A display driver for a screen, such as the SSD1306, exposes an image that represents the screen buffer. The driver typically can be used as an indexed screen service which provides simulation support.

import { SSD1306Driver, startIndexedScreen } from "@devicescript/drivers"

const screen = await startIndexedScreen(
new SSD1306Driver({ width: 128, height: 64, devAddr: 0x3c })
)
screen.image.print(`Hello world!`, 3, 10)
await screen.show()