@skillpet/circuit
Version:
Circuit diagram library — render electrical schematics from JSON, with interactive SVG, themes, and Vue/React components
37 lines (36 loc) • 1.35 kB
TypeScript
/**
* Color transition (lead gradients) between adjacent elements with different colors.
*
* When `colorTransition` is enabled, adjacent elements whose resolved colors differ
* get `<linearGradient>` defs applied to their connecting lead segments, producing
* a smooth color fade at the junction.
*/
import type { Element } from "./element.js";
import { Point } from "./geometry/point.js";
interface ConnectionEdge {
elA: Element;
elB: Element;
colorA: string;
colorB: string;
/** The absolute point where the two elements meet. */
junctionPt: Point;
}
/**
* Find pairs of elements that share a connection point (any pin anchor within
* tolerance) and have different resolved colors.
*
* Checks pin-level anchors (start, end, out, in1, in2, base, collector, etc.)
* so connections via named pins on multi-terminal elements are detected.
*/
export declare function buildConnectionGraph(elements: readonly Element[]): ConnectionEdge[];
/**
* Generate `<linearGradient>` defs for lead transition and assign `gradientStrokeId`
* on the relevant `Segment` objects.
*
* @param scale SVG scale factor (`PT_PER_IN * inchesPerUnit`)
*/
export declare function assignLeadTransitionIds(elements: readonly Element[], edges: ConnectionEdge[], scale: number): {
defsXml: string;
cleanup: () => void;
};
export {};