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>

57 lines (56 loc) 2.07 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 Circle = (function (_super) { __extends(Circle, _super); function Circle() { return _super !== null && _super.apply(this, arguments) || this; } Circle.prototype._sceneFunc = function (context) { context.beginPath(); context.arc(0, 0, this.radius(), 0, Math.PI * 2, false); context.closePath(); context.fillStrokeShape(this); }; Circle.prototype.getWidth = function () { return this.radius() * 2; }; Circle.prototype.getHeight = function () { return this.radius() * 2; }; Circle.prototype.setWidth = function (width) { if (this.radius() !== width / 2) { this.radius(width / 2); } }; Circle.prototype.setHeight = function (height) { if (this.radius() !== height / 2) { this.radius(height / 2); } }; return Circle; }(Shape_1.Shape)); exports.Circle = Circle; Circle.prototype._centroid = true; Circle.prototype.className = 'Circle'; Circle.prototype._attrsAffectingSize = ['radius']; Global_1._registerNode(Circle); Factory_1.Factory.addGetterSetter(Circle, 'radius', 0, Validators_1.getNumberValidator()); Util_1.Collection.mapMethods(Circle);