38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.Circle = void 0;
|
|
const Factory_1 = require("../Factory");
|
|
const Shape_1 = require("../Shape");
|
|
const Validators_1 = require("../Validators");
|
|
const Global_1 = require("../Global");
|
|
class Circle extends Shape_1.Shape {
|
|
_sceneFunc(context) {
|
|
context.beginPath();
|
|
context.arc(0, 0, this.attrs.radius || 0, 0, Math.PI * 2, false);
|
|
context.closePath();
|
|
context.fillStrokeShape(this);
|
|
}
|
|
getWidth() {
|
|
return this.radius() * 2;
|
|
}
|
|
getHeight() {
|
|
return this.radius() * 2;
|
|
}
|
|
setWidth(width) {
|
|
if (this.radius() !== width / 2) {
|
|
this.radius(width / 2);
|
|
}
|
|
}
|
|
setHeight(height) {
|
|
if (this.radius() !== height / 2) {
|
|
this.radius(height / 2);
|
|
}
|
|
}
|
|
}
|
|
exports.Circle = Circle;
|
|
Circle.prototype._centroid = true;
|
|
Circle.prototype.className = 'Circle';
|
|
Circle.prototype._attrsAffectingSize = ['radius'];
|
|
(0, Global_1._registerNode)(Circle);
|
|
Factory_1.Factory.addGetterSetter(Circle, 'radius', 0, (0, Validators_1.getNumberValidator)());
|