UNPKG

@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.

42 lines (41 loc) 957 B
import { Cursor } from "../types/Cursor.js"; import { ShapeStyle } from "./ShapeStyle.js"; /** * Represents the style options for a rectangle. */ export class RectangleStyle extends ShapeStyle { /** * The color of the border. */ borderColor; /** * The width of the border in pixels. */ borderWidth; /** * The fill color of the rectangle. */ color; /** * Default style for the rectangle. */ static DefaultStyle = { borderColor: '#000000', borderWidth: 0, color: '#000000', cursor: Cursor.Default }; /** * Creates a new instance of RectangleStyle. * * @param style - The partial style provided by the user. */ constructor(style = {}) { super(); const styleWithDefaults = { ...RectangleStyle.DefaultStyle, ...style }; Object.assign(this, styleWithDefaults); } }