Skip to content

toPNG

toPNG(device, framebuffer, width, height, texts?): string

Defined in: webgl/png.ts:23

Read a rendered framebuffer back to a PNG data URL. WebGL readback is bottom-left origin, so rows are flipped to top-left for the image. Browser only (uses a 2D canvas to encode). Render into framebuffer before calling. Pixels are written as they are, so a framebuffer blended premultiplied (as WebGLBackend draws, RGB × alpha) exports its translucent pixels darker: WebGLBackend.toPNG() exports its canvas instead (canvasToPNG).

texts (#219): screen-space labels composited on top of the readback via the shared 2D painter (the same one the Canvas backend renders with). Coordinates map 1:1 to the framebuffer’s pixels. Export-time only — never on a per-frame path.

Device

Framebuffer

number

number

readonly TextData[] = []

string