Skip to main content
An image the overlay can draw with render.image. Global class, no import.
Loading is asynchronous. width and height are 0 until ready is true, and render.image draws nothing before that.

Loading

constructor


Loads a PNG, JPG, BMP, TGA, GIF (first frame) or SVG. path is relative to the script folder. A missing file throws Error with code ENOENT.
Keep the images your script ships with in assets/. That folder is published and delivered to buyers with the script; data/ and other folders stay on your disk. See Folder layout.
width and height only apply to SVG and set its raster size.
Without the filesystem permission the file must be inside the script folder.

fromMemory


A texture from raw RGBA8 pixels: row-major, 4 bytes per pixel, no row padding. data is copied, so you can reuse it.

update


New pixels for the same texture, same size and format as fromMemory. This is how you animate one: draw a graph or a visualizer into a buffer and update one texture every frame. Making a new texture every frame is slow, and every one of them sits in GPU memory until it’s collected.
A file texture can only be updated once it’s ready (ENOTREADY before that).

Properties

toString() gives something like Texture(64x64, ready, "C:/…/logo.svg").

Example

A logo in the top-right corner at its real size, once it has loaded.