weasel API - v0.8.0
    Preparing search index...

    Function pointToGridCell

    • Compute the integer cell {col, row} that contains point, given a grid spacing and optional origin and unitSystem. Pair with createCellHighlightLayer (its getCell callback) to draw a snap-target preview that uses the same spacing as gridSnapStrategy — so the visual and behavioral grids stay in lockstep:

      const SPACING = 20;
      const snap = gridSnapStrategy(SPACING);
      // visual grid:
      createGridLayer({ spacing: SPACING, bounds: () => ... });
      // hover-preview overlay:
      createCellHighlightLayer({
        spacing: SPACING,
        getCell: () => hoverPoint && pointToGridCell(hoverPoint, SPACING),
      });
      

      Parameters

      • point: { x: number; y: number }
      • spacing: UnitValue
      • OptionalunitSystem: UnitSystem
      • origin: { x: number; y: number } = ...

      Returns { col: number; row: number }