@skillpet/circuit
Version:
Circuit diagram library — render electrical schematics from JSON, with interactive SVG, themes, and Vue/React components
169 lines (168 loc) • 5.03 kB
TypeScript
/**
* Integrated circuits — aligned with Python `elements/intcircuits.py` (subset + parity-oriented).
*/
import { Element } from "../element.js";
import { Point, type XY } from "../geometry/point.js";
export type IcSideId = "L" | "R" | "T" | "B";
export interface IcPinSpec {
name?: string | null;
pin?: string | null;
side: IcSideId;
pos?: number | null;
slot?: string | null;
invert?: boolean;
invertradius?: number;
color?: string | null;
rotation?: number;
anchorname?: string | null;
lblsize?: number | null;
pinlblsize?: number | null;
/** SVG hyperlink target (Python `IcPin.href`). */
href?: string | null;
/** `"underline"` / `"overline"` (Python `IcPin.decoration`). */
decoration?: string | null;
}
/**
* Python `elements.intcircuits.IcPin` dataclass — 可与 {@link Ic} 构造函数 / {@link Ic.pin} 混用。
*/
export declare class IcPin implements IcPinSpec {
name?: string | null;
pin?: string | null;
side: IcSideId;
pos?: number | null;
slot?: string | null;
invert: boolean;
invertradius: number;
color?: string | null;
rotation: number;
anchorname?: string | null;
lblsize?: number | null;
pinlblsize?: number | null;
href?: string | null;
decoration?: string | null;
constructor(opts?: Partial<IcPinSpec> & {
side?: string | IcSideId;
});
}
export interface IcSideParams {
spacing: number;
pad: number;
leadlen: number;
label_ofst: number;
label_size: number;
pinlabel_ofst: number;
pinlabel_size: number;
}
export interface IcBox {
w: number;
h: number;
y1: number;
y2: number;
}
export declare class Ic extends Element {
size?: [number, number];
slant: number;
pins: Record<IcSideId, IcPinSpec[]>;
usersides: Partial<Record<IcSideId, IcSideParams>>;
sides: Record<IcSideId, IcSideParams>;
pincount: Record<IcSideId, number>;
_sizeauto?: [number, number];
_icbox: IcBox;
private readonly _dflt;
constructor(opts?: {
size?: [number, number];
pins?: IcPinSpec[];
slant?: number;
label?: string;
} & Record<string, unknown>);
private mkSide;
pin(spec: Partial<IcPinSpec> & {
side?: string;
}): this;
side(sideStr: string, spacing?: number, pad?: number, leadlen?: number, label_ofst?: number, label_size?: number, pinlabel_ofst?: number, pinlabel_size?: number): this;
/** Python `Ic.pinnames` — logical pin names (anchorname or name). */
get pinnames(): string[];
/**
* Extends {@link Element.getAnchorNamesForGetattr} with {@link pinnames} and `pin{n}` (Python `Ic.__getattr__`).
*/
getAnchorNamesForGetattr(): string[];
/** Python `ic[name]`; same as {@link Element.resolveAnchor}. */
getPinAnchor(name: string): Point | undefined;
private _countpins;
private _autosize;
private _autopinlayout;
private _setsize;
private _drawBox;
private _pinpos;
private _drawClkpin;
private _drawPin;
private _drawPins;
_place(dwgxy: XY, dwgtheta: number, dwgparams: Record<string, unknown>): {
point: Point;
theta: number;
};
}
export declare class Multiplexer extends Ic {
constructor(opts?: {
demux?: boolean;
size?: [number, number];
pins?: IcPinSpec[];
slant?: number;
} & Record<string, unknown>);
}
export declare class DFlipFlop extends Ic {
constructor(opts?: {
preclr?: boolean;
preclrinvert?: boolean;
} & Record<string, unknown>);
}
export declare class JKFlipFlop extends Ic {
constructor(opts?: {
preclr?: boolean;
preclrinvert?: boolean;
} & Record<string, unknown>);
}
export declare class VoltageRegulator extends Ic {
constructor(opts?: Record<string, unknown>);
}
export declare class Ic555 extends Ic {
constructor(opts?: Record<string, unknown>);
}
/** 生成七段数码管几何片段(与 Python `sevensegdigit` 对齐)。 */
export declare function sevensegdigit(opts: {
bottom?: number;
left?: number;
seglen?: number;
segw?: number;
spacing?: number;
decimal?: boolean;
digit?: number | string;
segcolor?: string;
tilt?: number;
labelsegments?: boolean;
}): import("../segment.js").SegmentLike[];
export declare class SevenSegment extends Ic {
constructor(opts?: {
decimal?: boolean;
digit?: number | string;
segcolor?: string;
tilt?: number;
labelsegments?: boolean;
anode?: boolean;
cathode?: boolean;
} & Record<string, unknown>);
}
/** DIP 封装(双列直插)。 */
export declare class IcDIP extends Element {
constructor(opts?: {
pins?: number;
names?: string[];
notch?: boolean;
width?: number;
pinw?: number;
spacing?: number;
number?: boolean;
fontsize?: number;
pfontsize?: number;
} & Record<string, unknown>);
}