import GameObject from '../core/GameObject.js'; import Vector2 from '../math/Vector2.js'; /** * Configuration for creating a Line object. */ export interface LineProperties { /** Unique tag for identification. */ tag?: string; /** Hidden identifier linking runtime object to its source code location. */ __sourceId?: string; /** Stroke width of the line. */ width?: number; /** Start point of the line. */ p1: Vector2; /** End point of the line. */ p2: Vector2; /** Render order (lower is background). */ zIndex?: number; /** Whether the line is initially visible. */ visible?: boolean; /** Initial physics configuration. */ physics?: { velocity?: Vector2; acceleration?: Vector2; mass?: number; isStatic?: boolean; restitution?: number; friction?: number; isSensor?: boolean; }; } /** * A basic line object that can be drawn between two points. */ export default class Line extends GameObject { /** Stroke width of the line in pixels. */ strokeWidth: number; /** Start x coordinate in world space. */ x1: number; /** Start y coordinate in world space. */ y1: number; /** End x coordinate in world space. */ x2: number; /** End y coordinate in world space. */ y2: number; /** Gets the starting position of the line as a Vector2. */ get startPosition(): Vector2; /** * initialises a new instance of a Line. * @param props Configuration properties for the line. */ constructor(props: LineProperties); }