[d565449] | 1 | "use strict";
|
---|
| 2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 3 | exports.Star = void 0;
|
---|
| 4 | const Factory_1 = require("../Factory");
|
---|
| 5 | const Shape_1 = require("../Shape");
|
---|
| 6 | const Validators_1 = require("../Validators");
|
---|
| 7 | const Global_1 = require("../Global");
|
---|
| 8 | class Star extends Shape_1.Shape {
|
---|
| 9 | _sceneFunc(context) {
|
---|
| 10 | var innerRadius = this.innerRadius(), outerRadius = this.outerRadius(), numPoints = this.numPoints();
|
---|
| 11 | context.beginPath();
|
---|
| 12 | context.moveTo(0, 0 - outerRadius);
|
---|
| 13 | for (var n = 1; n < numPoints * 2; n++) {
|
---|
| 14 | var radius = n % 2 === 0 ? outerRadius : innerRadius;
|
---|
| 15 | var x = radius * Math.sin((n * Math.PI) / numPoints);
|
---|
| 16 | var y = -1 * radius * Math.cos((n * Math.PI) / numPoints);
|
---|
| 17 | context.lineTo(x, y);
|
---|
| 18 | }
|
---|
| 19 | context.closePath();
|
---|
| 20 | context.fillStrokeShape(this);
|
---|
| 21 | }
|
---|
| 22 | getWidth() {
|
---|
| 23 | return this.outerRadius() * 2;
|
---|
| 24 | }
|
---|
| 25 | getHeight() {
|
---|
| 26 | return this.outerRadius() * 2;
|
---|
| 27 | }
|
---|
| 28 | setWidth(width) {
|
---|
| 29 | this.outerRadius(width / 2);
|
---|
| 30 | }
|
---|
| 31 | setHeight(height) {
|
---|
| 32 | this.outerRadius(height / 2);
|
---|
| 33 | }
|
---|
| 34 | }
|
---|
| 35 | exports.Star = Star;
|
---|
| 36 | Star.prototype.className = 'Star';
|
---|
| 37 | Star.prototype._centroid = true;
|
---|
| 38 | Star.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];
|
---|
| 39 | (0, Global_1._registerNode)(Star);
|
---|
| 40 | Factory_1.Factory.addGetterSetter(Star, 'numPoints', 5, (0, Validators_1.getNumberValidator)());
|
---|
| 41 | Factory_1.Factory.addGetterSetter(Star, 'innerRadius', 0, (0, Validators_1.getNumberValidator)());
|
---|
| 42 | Factory_1.Factory.addGetterSetter(Star, 'outerRadius', 0, (0, Validators_1.getNumberValidator)());
|
---|