AutoCanvasRestore

class AutoCanvasRestore

Stack helper class calls Canvas.restoreToCount() when AutoCanvasRestore goes out of scope.

Use this to guarantee that the canvas is restored to a known state.

Example:

with skia.AutoCanvasRestore(canvas):
    canvas.drawCircle(50., 50., 10., paint)

Methods

__init__

Preserves Canvas.save() count.

restore

Restores Canvas to saved state immediately.

Methods

AutoCanvasRestore.__init__(self: skia.AutoCanvasRestore, canvas: SkCanvas, doSave: bool = True) None

Preserves Canvas.save() count.

Optionally saves Canvas clip and Canvas matrix.

Parameters:
Returns:

utility to restore Canvas state on destructor

AutoCanvasRestore.restore(self: skia.AutoCanvasRestore) None

Restores Canvas to saved state immediately.

Subsequent calls and destructor have no effect.