UNPKG

@tracespace/plotter

Version:

Plot @tracespace/parser ASTs into image trees.

83 lines (82 loc) 2.46 kB
import type { Node, Parent } from 'unist'; import type { UnitsType } from '@tracespace/parser'; export declare const IMAGE = "image"; export declare const IMAGE_SHAPE = "imageShape"; export declare const IMAGE_PATH = "imagePath"; export declare const IMAGE_REGION = "imageRegion"; export declare const LINE = "line"; export declare const ARC = "arc"; export declare const CIRCLE = "circle"; export declare const RECTANGLE = "rectangle"; export declare const POLYGON = "polygon"; export declare const OUTLINE = "outline"; export declare const LAYERED_SHAPE = "layeredShape"; export type Position = [x: number, y: number]; export type ArcPosition = [x: number, y: number, theta: number]; export type SizeEnvelope = [x1: number, y1: number, x2: number, y2: number] | []; export type ImageNode = ImageTree | ImageShape | ImagePath | ImageRegion; export interface CircleShape { type: typeof CIRCLE; cx: number; cy: number; r: number; } export interface RectangleShape { type: typeof RECTANGLE; x: number; y: number; xSize: number; ySize: number; r?: number; } export interface PolygonShape { type: typeof POLYGON; points: Position[]; } export interface OutlineShape { type: typeof OUTLINE; segments: PathSegment[]; } export interface LayeredShape { type: typeof LAYERED_SHAPE; shapes: ErasableShape[]; } export type HoleShape = CircleShape | RectangleShape; export type SimpleShape = CircleShape | RectangleShape | PolygonShape | OutlineShape; export type Shape = SimpleShape | LayeredShape; export type ErasableShape = SimpleShape & { erase?: boolean; }; export type ImageGraphic = ImageShape | ImagePath | ImageRegion; export interface ImageTree extends Parent { type: typeof IMAGE; units: UnitsType; size: SizeEnvelope; children: ImageGraphic[]; } export interface ImageShape extends Node { type: typeof IMAGE_SHAPE; shape: Shape; } export interface ImagePath extends Node { type: typeof IMAGE_PATH; width: number; segments: PathSegment[]; } export interface ImageRegion extends Node { type: typeof IMAGE_REGION; segments: PathSegment[]; } export type PathSegment = PathLineSegment | PathArcSegment; export interface PathLineSegment { type: typeof LINE; start: Position; end: Position; } export interface PathArcSegment { type: typeof ARC; start: ArcPosition; end: ArcPosition; center: Position; radius: number; }