Documentation / @ripl/canvas / rescaleCanvas
Function: rescaleCanvas() ​
rescaleCanvas(
canvas,ctx,width,height):RescaleResult
Defined in: canvas/src/utilities.ts:262
Sizes a canvas element's backing store for the device pixel ratio and returns the coordinate scales mapping logical pixels onto it.
The scales are returned whether or not the backing store needed resizing: they describe the requested logical size, which can change without the scaled integer dimensions changing.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
canvas | HTMLCanvasElement | The canvas whose backing store is sized. |
ctx | CanvasRenderingContext2D | The canvas's 2D context, whose transform is reset when the backing store changes. |
width | number | Requested width, in logical pixels. |
height | number | Requested height, in logical pixels. |
Returns ​
The updated coordinate scales.