-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
triangle.js
41 lines (37 loc) · 1.02 KB
/
triangle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import RegularPolygon from "@pencil.js/regular-polygon";
/**
* @module Triangle
*/
/**
* Triangle class
* <br><img src="./media/examples/triangle.png" alt="triangle demo"/>
* @class
* @extends {module:RegularPolygon}
*/
export default class Triangle extends RegularPolygon {
/**
* Triangle constructor
* @param {PositionDefinition} positionDefinition - Center of the triangle
* @param {Number} radius - Distance of branches from center
* @param {ComponentOptions} [options] - Drawing options
*/
constructor (positionDefinition, radius, options) {
super(positionDefinition, 3, radius, options);
}
/**
* @inheritDoc
*/
toJSON () {
const json = super.toJSON();
delete json.nbSides;
return json;
}
/**
* @inheritDoc
* @param {Object} definition - Triangle definition
* @return {Triangle}
*/
static from (definition) {
return new Triangle(definition.position, definition.radius, definition.options);
}
}