UNPKG

1.24 kBJavaScriptView Raw
1import { __extends } from "tslib";
2import Path from '../Path.js';
3var ArcShape = (function () {
4 function ArcShape() {
5 this.cx = 0;
6 this.cy = 0;
7 this.r = 0;
8 this.startAngle = 0;
9 this.endAngle = Math.PI * 2;
10 this.clockwise = true;
11 }
12 return ArcShape;
13}());
14export { ArcShape };
15var Arc = (function (_super) {
16 __extends(Arc, _super);
17 function Arc(opts) {
18 return _super.call(this, opts) || this;
19 }
20 Arc.prototype.getDefaultStyle = function () {
21 return {
22 stroke: '#000',
23 fill: null
24 };
25 };
26 Arc.prototype.getDefaultShape = function () {
27 return new ArcShape();
28 };
29 Arc.prototype.buildPath = function (ctx, shape) {
30 var x = shape.cx;
31 var y = shape.cy;
32 var r = Math.max(shape.r, 0);
33 var startAngle = shape.startAngle;
34 var endAngle = shape.endAngle;
35 var clockwise = shape.clockwise;
36 var unitX = Math.cos(startAngle);
37 var unitY = Math.sin(startAngle);
38 ctx.moveTo(unitX * r + x, unitY * r + y);
39 ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
40 };
41 return Arc;
42}(Path));
43Arc.prototype.type = 'arc';
44export default Arc;