Usage (signatures)
board.create('regularpolygon', [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 |
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('regularpolygon', [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}});
board.create('regularpolygon', [p1, p2, n]);
The constructed regular polygon has n vertices and the base line defined by p1 and p2.
Parameters
| Name | Type | Description |
|---|---|---|
p1 |
PointLike | |
p2 |
PointLike | |
n |
NumberLike |
Examples
var p1 = board.create('point', [0.0, 2.0]);
var p2 = board.create('point', [2.0, 1.0]);
var pol = board.create('regularpolygon', [p1, p2, 5]);
var p1 = board.create('point', [0.0, 2.0]);
var p2 = board.create('point', [4.0,4.0]);
var p3 = board.create('point', [2.0,0.0]);
var pol = board.create('regularpolygon', [p1, p2, p3]);
// Line of reflection
var li = board.create('line', [1,1,1], {strokeColor: '#aaaaaa'});
var reflect = board.create('transform', [li], {type: 'reflect'});
var pol1 = board.create('polygon', [[-3,-2], [-1,-4], [-2,-0.5]]);
var pol2 = board.create('polygon', [pol1, reflect]);
Attributes
Own
borders
- Description
Attributes for the polygon border lines.
- Type
- Line
- Overrides
- Polygon#borders
- Source
- options.js, line 8536
hasInnerPoints
- Description
If
true, moving the mouse over inner points triggers hasPoint.- Type
- Boolean
- Overrides
- Polygon#hasInnerPoints
- Default Value
- false
- See
- Source
- options.js, line 8511
label
- Description
Attributes for the polygon label.
- Type
- Label
- Overrides
- Polygon#label
- Source
- options.js, line 8569
vertices
- Description
Attributes for the polygon vertices.
- Type
- Point
- Overrides
- Polygon#vertices
- Source
- options.js, line 8554
withLines
- Description
Is the polygon bordered by lines?
- Type
- Boolean
- Overrides
- Polygon#withLines
- Default Value
- true
- Source
- options.js, line 8526
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
- Polygon
- Source
- base/polygon.js, line 1278