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.

95 lines (94 loc) 3.7 kB
import { LineDefinition } from "../definitions/LineDefinition.js"; import { ILineOptions } from "../options/interfaces/ILineOptions.js"; import { LineOptions } from "../options/LineOptions.js"; import { ILineStyle } from "../styles/interfaces/ILineStyle.js"; import { LineStyle } from "../styles/LineStyle.js"; import { Point } from "../types/Point.js"; import { Shape } from "./Shape.js"; /** * Represents a line shape that extends the generic Shape class. * It uses LineDefinition for defining the start and end points, * LineStyle for styling, and LineOptions for additional options. */ export declare class Line extends Shape<LineDefinition, LineStyle, LineOptions> { /** * @param start - The starting `Point` of the line. * @param end - The ending `Point` of the line. * @param style - Defines the styling of the line. * @param options - The configuration options for the line. */ constructor(start: Point, end: Point, style?: ILineStyle, options?: ILineOptions); /** * @param startX - The X-coordinate of the starting point. * @param startY - The Y-coordinate of the starting point. * @param endX - The X-coordinate of the ending point. * @param endY - The Y-coordinate of the ending point. * @param style - Defines the styling of the line. * @param options - The configuration options for the line. */ constructor(startX: number, startY: number, endX: number, endY: number, style?: ILineStyle, options?: ILineOptions); /** * Gets the starting point of the line. * * @returns The starting point of the line. */ get start(): Point; /** * Gets the ending point of the line. * * @returns The ending point of the line. */ get end(): Point; /** * Sets the starting point of the line. * * @param start - The new starting point of the line. */ set start(start: Point); /** * Sets the ending point of the line. * * @param end - The new ending point of the line. */ set end(end: Point); /** * Moves the start point of the line by the specified deltas along the x and y axes. * * @param deltaX - The amount to move the start point along the x-axis. * @param deltaY - The amount to move the start point along the y-axis. */ moveStart(deltaX?: number, deltaY?: number): void; /** * Moves the end point of the line by the specified deltas along the x and y axes. * * @param deltaX - The amount to move the end point along the x-axis. * @param deltaY - The amount to move the end point along the y-axis. */ moveEnd(deltaX?: number, deltaY?: number): void; /** * Moves the start & end point of the line by the specified deltas along the x and y axes. * * @param deltaX - The amount to move the start & end point along the x-axis. * @param deltaY - The amount to move the start & end point along the y-axis. */ move(deltaX?: number, deltaY?: number): void; /** * Renders the line on a canvas context. * * @param context - The canvas rendering context to draw the line. */ render(context: CanvasRenderingContext2D): void; /** * Determines if the mouse is currently over the shape. * * @param mousePosition - The current mouse position. * @returns True if the mouse is over the shape, false otherwise. */ isMouseOver(mousePosition: Point): boolean; /** * Handles the drag operation by applying the given delta to the current position. * * @param delta - The change in position represented as a `Point`. */ onDrag(delta: Point): void; }