2 ms·
There's two ways (one which you mentioned): - Use a ResizeObserver and observe a wrapper element, then resize and redraw your canvas when it notifies you. http
by esprehn 5y ago
There's two ways (one which you mentioned):
- Use a ResizeObserver and observe a wrapper element, then resize and redraw your canvas when it notifies you.
https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver https://developer.mozilla.org/en-US/docs/Web/API/ResizeObser...
- Use a Paint Worklet. It hooks directly into the browser painting system, but has some limitations on what you can draw with the canvas today.
https://developer.mozilla.org/en-US/docs/Web/API/PaintWorklet https://developer.mozilla.org/en-US/docs/Web/API/PaintWorkle...
You could also consider SVG instead of Canvas.
There's no way to automatically resize and replay draw commands but scaled up like you're asking though.