@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.
39 lines (38 loc) • 1.03 kB
JavaScript
import { ShapeOptions } from "./ShapeOptions.js";
/**
* Options for configuring the behavior of a rectangle shape.
*/
export class RectangleOptions {
/**
* Determines if the shape should be visible or not.
*/
visible;
/**
* Determines if the shape can be dragged by mouse.
*/
draggable;
/**
* If true, the rectangle will be centered at the provided position.
* If false or undefined, the rectangle will be positioned from the top-left corner.
*/
centered;
/**
* Default options for the rectangle.
*/
static DefaultOptions = {
...ShapeOptions.DefaultOptions,
centered: false
};
/**
* Creates a new instance of RectangleOptions.
*
* @param options - The partial options provided by the user.
*/
constructor(options = {}) {
const optionsWithDefaults = {
...RectangleOptions.DefaultOptions,
...options
};
Object.assign(this, optionsWithDefaults);
}
}