CanvasGl

@Composable
fun CanvasGl(width: Int, height: Int, modifier: Modifier = Modifier, variant: CssStyleVariant<CanvasKind>? = null, repainter: CanvasRepainter? = null, minDeltaMs: Number = if (repainter != null) REPAINT_CANVAS_MANUALLY else 0.0, maxDeltaMs: Number = max(500.0, minDeltaMs.toDouble()), ref: ElementRefScope<HTMLCanvasElement>? = null, render: RenderScope<WebGLRenderingContext>.() -> Unit)(source)

Renders a Canvas using the "webgl" rendering context.

Parameters

width

The width (in pixels) of this canvas. If the user adds a different value for the width in the modifier parameter, the canvas will be resized to fit.

height

The height (in pixels) of this canvas. Same additional details as width.

minDeltaMs

If set, ensures that draw won't be called more than once per this period. If not set, render will be called as frequently as possible. The constant ONE_FRAME_MS_60_FPS could be useful to set here.

maxDeltaMs

Ensured that the delta passed into RenderScope will be capped. This is useful to make sure that render behavior doesn't explode after sitting on a breakpoint for a while or get stuck on some edge case long calculation. By default, it is capped to half a second.

repainter

If present, provides a handle that lets callers trigger a repaint manually. You should declare the CanvasRepainter instance inside a remember block.

render

A callback which handles rendering a single frame.