Skip to content

3.4 Polygon

Jonas de Luna Skulberg edited this page Jun 26, 2024 · 3 revisions

Polygon

Extends:

Implements:

Parameters:

Required:

  • vertices: InputPosition, InputPosition, InputPosition, ...InputPosition[]

Optional:

  • color?: number Color of the Polygon fill.
  • fill?: boolean Whether the Polygon should be filled.
  • opacity?: number Opacity of the Polygon fill.
  • draggable?: Draggable Whether the Polygon should be draggable.
  • dragListeners?: ((point: Polygon) => void)[] Initial dragListeners that can be added upon construction of the Polygon.
  • hasOutline: boolean Whether he Polygon should have an outline

Default Parameters:

  color: 0xfaa307,
  opacity: 0.6,
  draggable: undefined,
  dragListeners: [],
  hasOutline: true,

Implemented Methods:

  • collidesWith(other: Object3D): boolean
  • distanceTo(other: Object3D<Event>): number
  • addDragListener(listener: (point: Point) => void) Adds a draglistener to the polygon. The parameter of the listenerfunction takes in a reference to the instance of the polygon the listener is attached to.

Methods

  • setPosition(position: InputPosition) Set the position of the polygon to a specified center position.
  • setVertices(newVertices: PolygonVertices) Sets a new set of points and updates the polygon.
Clone this wiki locally