Reference · Markers on the globe
canvasRatiofunction
The pixel ratio for an overlay canvas: the device's, to 2, held to 4096 a side and 6 million pixels (the same budget as the 3D canvas).
Import it
import { canvasRatio } from "@johnmorrisdotca/chikyu-earth/markers";
Definition
function canvasRatio(width: number, height: number, deviceRatio: number, maxSide?: number, maxPixels?: number): number
Parameters
| Name | Type | Description |
|---|---|---|
width | number | The canvas's width in CSS pixels. |
height | number | The canvas's height in CSS pixels. |
deviceRatio | number | The device's pixel ratio. |
maxSide (optional) | number | The most pixels on a side. |
maxPixels (optional) | number | The most pixels in all. |
Returns
number
The ratio to draw at, between 0.1 and 2.
Examples
import { canvasRatio } from "@johnmorrisdotca/chikyu-earth/markers";
console.log(canvasRatio(420, 420, 3), canvasRatio(5000, 3000, 2));2 0.6324555320336759What it prints (run when this page was built)