1 | import { __extends } from "tslib";
|
2 | import Path from '../Path.js';
|
3 | var 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 | }());
|
12 | export { EllipseShape };
|
13 | var 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));
|
38 | Ellipse.prototype.type = 'ellipse';
|
39 | export default Ellipse;
|