@avolutions/canvas-painter
Version:
CanvasPainter.js is a simple yet powerful JavaScript library for drawing basic shapes (rectangles, circles, etc.) on HTML5 Canvas with ease. Perfect for creating 2D graphics in your web projects.
43 lines (42 loc) • 1.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CircleDefinition = void 0;
const ShapeDefinition_js_1 = require("./ShapeDefinition.js");
/**
* Class representing a circle definition.
*/
class CircleDefinition extends ShapeDefinition_js_1.ShapeDefinition {
/**
* Creates an instance of CircleDefinition.
*
* @param center - The center point of the circle.
* @param radius - The radius of the circle.
*/
constructor(center, radius) {
super();
this.center = center;
this.radius = radius;
}
/**
* Gets the radius of the definition.
*
* @returns The radius of the definition.
*/
get radius() {
return this._radius;
}
/**
* Sets the radius of the definition.
*
* @param radius - The new radius of the definition.
*
* @throws RangeError if negative radius is passed.
*/
set radius(radius) {
if (radius < 0) {
throw new RangeError("Radius must be a positive number");
}
this._radius = radius;
}
}
exports.CircleDefinition = CircleDefinition;