iink-ts - v5.0.0
    Preparing search index...

    Class Polygon2d

    Hierarchy (View Summary)

    Index
    • get bounds(): TOBB

      The smallest box containing every vertex, measured in this shape's own frame.

      Axis-aligned while frameAngle is zero, and turned with the shape once it is not — which is what keeps a rotated shape's box tight instead of letting it grow to the axis-aligned box around the turned one.

      Returns TOBB

    • get edges(): TSegment[]

      The segments between consecutive vertices, plus the closing one when isClosed.

      That closing edge is the whole of what isClosed changes here, and it is not cosmetic: without it a polygon's last side is missing from every edge-crossing test, so a query touching only that side would report no overlap.

      Returns TSegment[]

    • get length(): number

      Total length along the edges — a perimeter when isClosed, a path length otherwise.

      Returns number

    • get vertices(): TPoint[]

      Returns TPoint[]

    • Parameters

      • points: TPoint[]
      • isFilled: boolean = false
      • frameAngle: number = 0

      Returns Polygon2d

    • The points this shape is made of, in order.

      A curve tessellates here — there is no exact vertex list for a circle, and the subclass that draws one decides how finely to approximate it. A shape whose test does not need an approximation overrides the methods that would use it instead.

      Implemented rather than exposed directly so the result can be held: see the class note.

      Returns TPoint[]

    • Whether point is inside this shape's outline.

      Always false for an unfilled shape: there is no inside to be in. Callers wanting "on or near the outline" want hitTestPoint.

      Parameters

      Returns boolean

    • Distance from point to this shape's outline. Zero on the outline, positive on either side.

      Parameters

      Returns number

    • Whether point hits this shape, allowing margin of slack around its outline.

      Inside a filled shape counts however far from the outline it is — that is what filled means.

      Parameters

      • point: TPoint
      • margin: number = 0

      Returns boolean

    • This shape's points carried through matrix, for a subclass to hand to the shape it builds.

      Exact however the matrix turns or scales — a point maps to a point, with nothing to approximate and no accumulated tessellation error to carry.

      Parameters

      Returns TPoint[]

    • Whether this shape and an axis-aligned query box share any area.

      Concrete, and the generic answer for anything made of straight edges: the shape sits inside the query, or an edge crosses it, or — for a filled shape only — the query sits inside the shape.

      A subclass overrides this when it has an exact test of its own that a vertex list can only approximate, which for a curve it always can.

      Parameters

      Returns boolean

    • A polygon's vertices are its exact shape, so moving them is exact however the matrix turns or scales — no approximation to carry forward. The frame goes with them, because the tight box around a turned polygon is only tight in a frame that turned too.

      Parameters

      Returns Polygon2d

    frameAngle: number
    isClosed: boolean
    isFilled: boolean
    padding: number
    points: TPoint[]

    Read directly rather than through Geometry2d.vertices by subclasses on a hot path: the getter memoizes, so both give the same array, but hit-testing calls this once per sample.