import { Vector2D } from '../Vector2D'; import { Matrix } from '../Matrix'; import { Point } from './Point'; import { Line } from './Line'; import { Circle } from './Circle'; import { Rectangle } from './Rectangle'; import { Polygon } from './Polygon'; import { Polyline } from './Polyline'; export abstract class Shape { abstract clone(): Shape; abstract isNull(): boolean; abstract fuzzyIsNull(epsilon?: number): boolean; abstract equals(other: Shape): boolean; abstract fuzzyEquals(other: Shape, epsilon?: number): boolean; abstract translate(dx: number, dy: number): this; abstract translated(dx: number, dy: number): Shape; abstract transform(matrix: Matrix): this; abstract transformed(matrix: Matrix): Shape; abstract draw(context: CanvasRenderingContext2D, stroked?: boolean, filled?: boolean): void; render(context: CanvasRenderingContext2D, strokeStyle?: string | CanvasGradient | CanvasPattern, fillStyle?: string | CanvasGradient | CanvasPattern) { const ctxStrokeStyle = context.strokeStyle; const ctxFillStyle = context.fillStyle; const stroked = strokeStyle !== undefined; const filled = fillStyle !== undefined; if (stroked) context.strokeStyle = strokeStyle as NonNullable; if (filled) context.fillStyle = fillStyle as NonNullable; this.draw(context, stroked, filled); context.strokeStyle = ctxStrokeStyle; context.fillStyle = ctxFillStyle; } abstract boundingRectangle(): Rectangle; abstract containsPoint(other: Point, epsilon?: number): boolean; abstract containsLine(other: Line, epsilon?: number): boolean; abstract containsCircle(other: Circle, epsilon?: number): boolean; abstract containsRectangle(other: Rectangle, epsilon?: number): boolean; abstract containsPolygon(other: Polygon, epsilon?: number): boolean; abstract containsPolyline(other: Polyline, epsilon?: number): boolean; abstract contains(other: Shape, epsilon?: number): boolean; abstract intersectsPoint(other: Point, callbackfn?: (points: Vector2D[], thisShape: Shape, otherShape: Shape) => any, thisArg?: any, epsilon?: number): boolean; abstract intersectsLine(other: Line, callbackfn?: (points: Vector2D[], thisShape: Shape, otherShape: Shape) => any, thisArg?: any, epsilon?: number): boolean; abstract intersectsCircle(other: Circle, callbackfn?: (points: Vector2D[], thisShape: Shape, otherShape: Shape) => any, thisArg?: any, epsilon?: number): boolean; abstract intersectsRectangle(other: Rectangle, callbackfn?: (points: Vector2D[], thisShape: Shape, otherShape: Shape) => any, thisArg?: any, epsilon?: number): boolean; abstract intersectsPolygon(other: Polygon, callbackfn?: (points: Vector2D[], thisShape: Shape, otherShape: Shape) => any, thisArg?: any, epsilon?: number): boolean; abstract intersectsPolyline(other: Polyline, callbackfn?: (points: Vector2D[], thisShape: Shape, otherShape: Shape) => any, thisArg?: any, epsilon?: number): boolean; abstract intersects(other: Shape, callbackfn?: (points: Vector2D[], thisShape: Shape, otherShape: Shape) => any, thisArg?: any, epsilon?: number): boolean; intersectsSelf(callbackfn?: (points: Vector2D[], thisShape: Shape, otherShape: Shape) => any, thisArg?: any, epsilon?: number) { return false; } }