@skillpet/circuit
Version:
Circuit diagram library — render electrical schematics from JSON, with interactive SVG, themes, and Vue/React components
59 lines (58 loc) • 1.55 kB
TypeScript
import { type Theme } from "./theme.js";
export interface DrawingConfig {
unit?: number;
font?: string;
fontsize?: number;
color?: string;
lw?: number;
bgcolor?: string;
colorTransition?: boolean;
}
export interface LabelSpec {
text: string;
loc?: string;
ofst?: number | [number, number];
halign?: "left" | "center" | "right";
valign?: "top" | "center" | "bottom" | "base";
rotate?: boolean | number;
fontsize?: number;
color?: string;
}
export interface ElementObject {
type: string;
id?: string;
d?: "up" | "down" | "left" | "right";
theta?: number;
at?: [number, number] | string;
to?: [number, number] | string;
tox?: number | string;
toy?: number | string;
l?: number;
flip?: boolean;
reverse?: boolean;
anchor?: string;
scale?: number;
label?: string | LabelSpec;
labels?: LabelSpec[];
color?: string;
fill?: string;
lw?: number;
ls?: string;
dot?: boolean | "open";
idot?: boolean | "open";
params?: Record<string, unknown>;
tooltip?: string;
meta?: Record<string, unknown>;
}
export type ElementSpec = ElementObject | "push" | "pop";
export interface RenderOptions {
theme?: string | Partial<Theme>;
interactive?: boolean;
colorTransition?: boolean;
}
export interface CircuitJson {
theme?: string | Partial<Theme>;
drawing?: DrawingConfig;
elements: ElementSpec[];
}
export declare function renderFromJson(json: CircuitJson | string, opts?: RenderOptions): string;