CanvasRepainter

A helper class which lets callers trigger a repaint manually.

Pass it into a Canvas2d (or CanvasGl) as follows:

val repainter = remember { CanvasRepainter() }
Canvas2d(
500, 500,
Modifier.onClick { repainter.repaint() },
repainter = repainter
) {
ctx.fillStyle = Color.rgb(Random.nextInt(255), Random.nextInt(255), Random.nextInt(255))
ctx.fillRect(0.0, 0.0, 500.0, 500.0)
}

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
fun repaint()