canvasRatio関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
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 { canvasRatio } from "@johnmorrisdotca/chikyu-earth/markers";
定義
function canvasRatio(width: number, height: number, deviceRatio: number, maxSide?: number, maxPixels?: number): number
引数
| 名前 | 型 | 説明 |
|---|---|---|
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 (省略可) | number | The most pixels on a side. |
maxPixels (省略可) | number | The most pixels in all. |
戻り値
number
The ratio to draw at, between 0.1 and 2.
例
import { canvasRatio } from "@johnmorrisdotca/chikyu-earth/markers";
console.log(canvasRatio(420, 420, 3), canvasRatio(5000, 3000, 2));2 0.6324555320336759出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。