Skip to content

Function: screenToLayout() ​

ts
function screenToLayout(
   layout, 
   box, 
   clientX, 
   clientY
): Vec;

Convert a screen point (e.g. a pointer event's clientX, clientY) to layout units, given the box of the element the layout fills: a <TileLayout> container, an <svg> with the layout's viewBox, or a canvas you drew it on. Like SVG's default preserveAspectRatio, the layout is taken to be scaled to fit the box and centerd.

Parameters ​

ParameterType
layoutLayout
boxScreenBox
clientXnumber
clientYnumber

Returns ​

Vec

Hat tiling and isohedral tilings after Craig S. Kaplan's hatviz and Tactile (BSD 3-Clause).