@mocanvas/mocanvas · function

withCamera

declare function withCamera(ctx: CanvasRenderingContext2D, camera: CameraLike, draw: (ctx: CanvasRenderingContext2D) => void): void

Run draw with the camera installed, so everything inside is in **page** coordinates. Restores the context afterwards, even if draw throws.

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.