visibleAreafunction
The part of the board the view shows.
Import it
import { visibleArea } from "@johnmorrisdotca/meikyuu/play";
Definition
function visibleArea(view: View, box: ViewBox): Box
Parameters
| Name | Type | Description |
|---|---|---|
view | View | The current pan and scale. |
box | ViewBox | The viewport dimensions and logical board bounds, or board bounds specified by the signature. |
Returns
Box
The part of the board the view shows.
Examples
import type { MazeRecipe } from "@johnmorrisdotca/meikyuu";
import { buildMaze } from "@johnmorrisdotca/meikyuu";
import { fitView, visibleArea } from "@johnmorrisdotca/meikyuu/play";
const recipe: MazeRecipe = {shape:"square",w:5,h:5,algorithm:"backtracker",mode:"to-goal",seed:42};
const maze = buildMaze(recipe);
const grid = maze.grid;
const box = {width:390,height:844,area:grid.box};
const view = fitView(box);
console.log(visibleArea(view,box));{
x: -0.6000000000000001,
y: -4.20871794871795,
w: 6.2,
h: 13.4174358974359
}What it prints (run when this page was built)