source: imaps-frontend/node_modules/konva/lib/shapes/Star.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.6 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.Star = void 0;
4const Factory_1 = require("../Factory");
5const Shape_1 = require("../Shape");
6const Validators_1 = require("../Validators");
7const Global_1 = require("../Global");
8class 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}
35exports.Star = Star;
36Star.prototype.className = 'Star';
37Star.prototype._centroid = true;
38Star.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];
39(0, Global_1._registerNode)(Star);
40Factory_1.Factory.addGetterSetter(Star, 'numPoints', 5, (0, Validators_1.getNumberValidator)());
41Factory_1.Factory.addGetterSetter(Star, 'innerRadius', 0, (0, Validators_1.getNumberValidator)());
42Factory_1.Factory.addGetterSetter(Star, 'outerRadius', 0, (0, Validators_1.getNumberValidator)());
Note: See TracBrowser for help on using the repository browser.