Polygon

Element

A polygon is a plane figure made up of line segments (the borders) connected to form a closed polygonal chain. It is determined by

  • a list of points or
  • a list of coordinate arrays or
  • a function returning a list of coordinate arrays.

Each two consecutive points of the list define a line.

Usage (signatures)
board.create('polygon', [vertices]);
Parameters
Name Type Description
vertices Array

The polygon's vertices. If the first and the last vertex don't match the first one will be added to the array by the creator. Here, two points match if they have the same id attribute.

Examples
var p1 = board.create('point', [0.0, 2.0]);
var p2 = board.create('point', [2.0, 1.0]);
var p3 = board.create('point', [4.0, 6.0]);
var p4 = board.create('point', [1.0, 4.0]);

var pol = board.create('polygon', [p1, p2, p3, p4]);
var p = [[0.0, 2.0], [2.0, 1.0], [4.0, 6.0], [1.0, 3.0]];

var pol = board.create('polygon', p, {hasInnerPoints: true});
var f1 = () => [0.0, 2.0],
      f2 = () => [2.0, 1.0],
      f3 = () => [4.0, 6.0],
      f4 = () => [1.0, 4.0],
      cc1 = board.create('polygon', [f1, f2, f3, f4]);
      board.update();

board.create('polygon', [pol, t]);

Additionally, a polygon can be created by providing a polygon and a transformation (or an array of transformations). The result is a polygon which is the transformation of the supplied polygon.

Parameters
Name Type Description
pol Polygon
t Transformation
Example
var t = board.create('transform', [2, 1.5], {type: 'scale'});
var a = board.create('point', [-3,-2], {name: 'a'});
var b = board.create('point', [-1,-4], {name: 'b'});
var c = board.create('point', [-2,-0.5], {name: 'c'});
var pol1 = board.create('polygon', [a,b,c], {vertices: {withLabel: false}});
var pol2 = board.create('polygon', [pol1, t], {vertices: {withLabel: true}});

Attributes

Own

borders

Description

Attributes for the polygon border lines.

Type
Line
Overrides
JXG.Polygon#borders
Source
options.js, line 8359

hasInnerPoints

Description

If true, moving the mouse over inner points triggers hasPoint.

Type
Boolean
Default Value
false
See
Source
options.js, line 8331

highlightByStrokeWidth

Description

By default, the strokewidths of the borders of a polygon are not changed during highlighting (only strokeColor and strokeOpacity are changed to highlightStrokeColor, and highlightStrokeOpacity). However, strokewidth is changed to highlightStrokewidth if an individual border gets the focus.

With this attribute set to true, also the borders change strokeWidth if the polygon itself gets the focus.

Type
Boolean
Default Value
false
Source
options.js, line 8378

label

Description

Attributes for the polygon label.

Type
Label
Source
options.js, line 8409

vertices

Description

Attributes for the polygon vertices.

Type
Point
Overrides
JXG.Polygon#vertices
Source
options.js, line 8392

withLines

Description

Is the polygon bordered by lines?

Type
Boolean
Default Value
true
Source
options.js, line 8349

Inherited

Members

Own

none

Inherited

Methods

Own

none

Inherited

Events

Own

none

Inherited

Throws

If the element cannot be constructed with the given parent objects an exception is thrown.

Type
Exception

Details

Type
JXG.Polygon
Source
base/polygon.js, line 1116

Extends