Class PolygonObject

An opaque polygon object

Hierarchy

Constructors

Properties

diffuse: number

The intensity of the light penetration in objects.

Default

0.8
points: Vec2[]

An array of Vec points that define the polygon.

Default

[]

Methods

  • Calculate the boundaries of the polygon object.

    Returns Bounds

    An anonymous object with the properties topLeft and bottomRight. The property values are Vec2 objects representing the corners of the boundary.

  • Fill ctx with the shadows projected by the polygon object from the origin point, constrained by the given bounds.

    Parameters

    • context: CanvasRenderingContext2D

      The canvas context onto which the shadows will be cast.

    • origin: Vec2

      A vector that represents the origin for the casted shadows.

    • bounds: Bounds

      An anonymous object with the properties topLeft and bottomRight. The property values are Vec2 objects representing the corners of the boundary.

    Returns void

  • Determine if the given point is inside the polygon.

    Parameters

    • point: Vec2

      The point to be checked.

    Returns boolean

    true if the polygon object contains the given point.

  • Invoke a function for each of the visible edges in the polygon.

    Parameters

    • origin: Vec2

      A vector that represents the origin for the casted shadows.

    • bounds: Bounds

      An anonymous object with the properties topLeft and bottomRight. The property values are Vec2 objects representing the corners of the boundary of the polygon.

    • callback: ((a, b, originToA, originToB, aToB) => void)

      The function to be invoked.

        • (a, b, originToA, originToB, aToB): void
        • Parameters

          Returns void

    Returns void

  • Draw the path of the polygon onto the ctx.

    Parameters

    • context: CanvasRenderingContext2D

      The context onto which the path will be drawn.

    Returns void