Reference · Framing, geometry and quiz tools
wrapAcrossfunction
A coordinate brought back onto the canvas, for a pan that has gone round.
Import it
import { wrapAcross } from "@johnmorrisdotca/chizu";
Definition
function wrapAcross(x: number, width: number): number
Parameters
| Name | Type | Description |
|---|---|---|
x | number | The horizontal native map coordinate. |
width | number | The native canvas width or frame width specified by this signature. |
Returns
number
A coordinate brought back onto the canvas, for a pan that has gone round.
Examples
import { wrapAcross } from "@johnmorrisdotca/chizu";
console.log(wrapAcross(1030, 1000), wrapAcross(-20, 1000), wrapAcross(500, 1000));
// 30 980 50030 980 500What it prints (run when this page was built)