source: imaps-frontend/node_modules/konva/lib/shapes/Arc.js

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

Update repo after prototype presentation

  • Property mode set to 100644
File size: 2.6 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.Arc = void 0;
4const Factory_1 = require("../Factory");
5const Shape_1 = require("../Shape");
6const Global_1 = require("../Global");
7const Validators_1 = require("../Validators");
8const Global_2 = require("../Global");
9class Arc extends Shape_1.Shape {
10 _sceneFunc(context) {
11 var angle = Global_1.Konva.getAngle(this.angle()), clockwise = this.clockwise();
12 context.beginPath();
13 context.arc(0, 0, this.outerRadius(), 0, angle, clockwise);
14 context.arc(0, 0, this.innerRadius(), angle, 0, !clockwise);
15 context.closePath();
16 context.fillStrokeShape(this);
17 }
18 getWidth() {
19 return this.outerRadius() * 2;
20 }
21 getHeight() {
22 return this.outerRadius() * 2;
23 }
24 setWidth(width) {
25 this.outerRadius(width / 2);
26 }
27 setHeight(height) {
28 this.outerRadius(height / 2);
29 }
30 getSelfRect() {
31 const innerRadius = this.innerRadius();
32 const outerRadius = this.outerRadius();
33 const clockwise = this.clockwise();
34 const angle = Global_1.Konva.getAngle(clockwise ? 360 - this.angle() : this.angle());
35 const boundLeftRatio = Math.cos(Math.min(angle, Math.PI));
36 const boundRightRatio = 1;
37 const boundTopRatio = Math.sin(Math.min(Math.max(Math.PI, angle), (3 * Math.PI) / 2));
38 const boundBottomRatio = Math.sin(Math.min(angle, Math.PI / 2));
39 const boundLeft = boundLeftRatio * (boundLeftRatio > 0 ? innerRadius : outerRadius);
40 const boundRight = boundRightRatio * (boundRightRatio > 0 ? outerRadius : innerRadius);
41 const boundTop = boundTopRatio * (boundTopRatio > 0 ? innerRadius : outerRadius);
42 const boundBottom = boundBottomRatio * (boundBottomRatio > 0 ? outerRadius : innerRadius);
43 return {
44 x: boundLeft,
45 y: clockwise ? -1 * boundBottom : boundTop,
46 width: boundRight - boundLeft,
47 height: boundBottom - boundTop,
48 };
49 }
50}
51exports.Arc = Arc;
52Arc.prototype._centroid = true;
53Arc.prototype.className = 'Arc';
54Arc.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];
55(0, Global_2._registerNode)(Arc);
56Factory_1.Factory.addGetterSetter(Arc, 'innerRadius', 0, (0, Validators_1.getNumberValidator)());
57Factory_1.Factory.addGetterSetter(Arc, 'outerRadius', 0, (0, Validators_1.getNumberValidator)());
58Factory_1.Factory.addGetterSetter(Arc, 'angle', 0, (0, Validators_1.getNumberValidator)());
59Factory_1.Factory.addGetterSetter(Arc, 'clockwise', false, (0, Validators_1.getBooleanValidator)());
Note: See TracBrowser for help on using the repository browser.