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.
Parameters
Section titled “Parameters”device
Section titled “device”Device
framebuffer
Section titled “framebuffer”Framebuffer
number
height
Section titled “height”number
texts?
Section titled “texts?”readonly TextData[] = []
Returns
Section titled “Returns”string