Skip to main content

pickShape

The id of the topmost shape a tap at at lands on, or null. Later shapes are on top. A line, a point and the edge of a polygon or circle are hit within tolerancePx; with interior (the default) the inside of a polygon or circle is hit too, and without it a tap inside an area passes through, so a new shape can be started there.

This is a function exported by @mapcairn/core, checked against version 0.2.0.

Signature​

import { pickShape } from "@mapcairn/core";

function pickShape(shapes: readonly DrawShape[], at: PixelPoint, placement: MapPlacement, tolerancePx: number, interior?: boolean): string | null;

Parameters​

  • shapes (readonly DrawShape[])
  • at (PixelPoint)
  • placement (MapPlacement): How the overlay places shapes on the screen, so a tap meets the same curves, the same copy of the world and the same horizon as the drawing. Nothing beyond the horizon of a globe is hit, and an area's inside counts only while all of its outline is in sight.
  • tolerancePx (number)
  • interior? (boolean)

Returns​

string | null

See also​

Source: packages/core/src/draw/hit.ts:176