UNPKG

konva

Version:

<p align="center"> <img src="https://raw.githubusercontent.com/konvajs/konvajs.github.io/master/apple-touch-icon-180x180.png" alt="Konva logo" height="180" /> </p>

61 lines (60 loc) 2.32 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var Util_1 = require("../Util"); var Factory_1 = require("../Factory"); var Shape_1 = require("../Shape"); var Validators_1 = require("../Validators"); var Global_1 = require("../Global"); var Ellipse = (function (_super) { __extends(Ellipse, _super); function Ellipse() { return _super !== null && _super.apply(this, arguments) || this; } Ellipse.prototype._sceneFunc = function (context) { var rx = this.radiusX(), ry = this.radiusY(); context.beginPath(); context.save(); if (rx !== ry) { context.scale(1, ry / rx); } context.arc(0, 0, rx, 0, Math.PI * 2, false); context.restore(); context.closePath(); context.fillStrokeShape(this); }; Ellipse.prototype.getWidth = function () { return this.radiusX() * 2; }; Ellipse.prototype.getHeight = function () { return this.radiusY() * 2; }; Ellipse.prototype.setWidth = function (width) { this.radiusX(width / 2); }; Ellipse.prototype.setHeight = function (height) { this.radiusY(height / 2); }; return Ellipse; }(Shape_1.Shape)); exports.Ellipse = Ellipse; Ellipse.prototype.className = 'Ellipse'; Ellipse.prototype._centroid = true; Ellipse.prototype._attrsAffectingSize = ['radiusX', 'radiusY']; Global_1._registerNode(Ellipse); Factory_1.Factory.addComponentsGetterSetter(Ellipse, 'radius', ['x', 'y']); Factory_1.Factory.addGetterSetter(Ellipse, 'radiusX', 0, Validators_1.getNumberValidator()); Factory_1.Factory.addGetterSetter(Ellipse, 'radiusY', 0, Validators_1.getNumberValidator()); Util_1.Collection.mapMethods(Ellipse);