UNPKG

1.18 kBJavaScriptView Raw
1import { __extends } from "tslib";
2import Path from '../Path.js';
3var EllipseShape = (function () {
4 function EllipseShape() {
5 this.cx = 0;
6 this.cy = 0;
7 this.rx = 0;
8 this.ry = 0;
9 }
10 return EllipseShape;
11}());
12export { EllipseShape };
13var Ellipse = (function (_super) {
14 __extends(Ellipse, _super);
15 function Ellipse(opts) {
16 return _super.call(this, opts) || this;
17 }
18 Ellipse.prototype.getDefaultShape = function () {
19 return new EllipseShape();
20 };
21 Ellipse.prototype.buildPath = function (ctx, shape) {
22 var k = 0.5522848;
23 var x = shape.cx;
24 var y = shape.cy;
25 var a = shape.rx;
26 var b = shape.ry;
27 var ox = a * k;
28 var oy = b * k;
29 ctx.moveTo(x - a, y);
30 ctx.bezierCurveTo(x - a, y - oy, x - ox, y - b, x, y - b);
31 ctx.bezierCurveTo(x + ox, y - b, x + a, y - oy, x + a, y);
32 ctx.bezierCurveTo(x + a, y + oy, x + ox, y + b, x, y + b);
33 ctx.bezierCurveTo(x - ox, y + b, x - a, y + oy, x - a, y);
34 ctx.closePath();
35 };
36 return Ellipse;
37}(Path));
38Ellipse.prototype.type = 'ellipse';
39export default Ellipse;