Reference · Rules, tiles and records
fitViewfunction
The view that shows the whole area, centred, its tiles as big as fit between the least and the most. A picture nobody presses (a finished grid, the set-up preview) passes a smaller least, so a whole grid fits its box.
Import it
import { fitView } from "@johnmorrisdotca/kumimoji";
Definition
function fitView(area: Area, width: number, height: number, least?: number): View
Parameters
| Name | Type | Description |
|---|---|---|
area | Area | The occupied table bounds. |
width | number | The available viewport width in pixels. |
height | number | The available viewport height in pixels. |
least (optional) | number | The minimum permitted tile size. |
Returns
View
The view that shows the whole area, centred, its tiles as big as fit between the least and the most. A picture nobody presses (a finished grid, the set-up preview) passes a smaller least, so a whole grid fits its box.
Examples
import { fitView } from "@johnmorrisdotca/kumimoji";
const area = {top:0,left:0,rows:1,cols:3};
console.log(fitView(area,640,480));{ tile: 56, x: 236, y: 212 }What it prints (run when this page was built)