/** * EasyEDA Symbol to KiCad Symbol Converter * Converts EasyEDA symbol format to KiCad .kicad_sym format (KiCad 9 compatible) */ import type { EasyEDAComponentData } from '../types/index.js'; export interface SymbolConversionOptions { libraryName?: string; symbolName?: string; includeDatasheet?: boolean; includeManufacturer?: boolean; } export declare class SymbolConverter { /** * Convert EasyEDA component data to KiCad symbol format string (standalone library) */ convert(component: EasyEDAComponentData, options?: SymbolConversionOptions): string; /** * Convert component to a symbol entry (without library wrapper) * Used for appending to existing libraries */ convertToSymbolEntry(component: EasyEDAComponentData, options?: SymbolConversionOptions): string; /** * Generate symbol from fixed template (for passives) */ private generateFromTemplate; /** * Generate symbol from EasyEDA data (for ICs and complex components) * Uses parsed shapes if available, otherwise falls back to DIP-style layout */ private generateFromEasyEDA; /** * Check if symbol has shapes worth rendering (not just pins) */ private hasRenderableShapes; /** * Generate symbol using parsed EasyEDA shapes */ private generateFromShapes; /** * Convert EasyEDA X coordinate to KiCad (with origin offset) */ private convertX; /** * Convert EasyEDA Y coordinate to KiCad (Y-flipped with origin offset) */ private convertY; /** * Convert stroke width from EasyEDA to KiCad */ private convertStrokeWidth; /** * Convert EasyEDA rectangle to KiCad format */ private convertRectangle; /** * Convert EasyEDA circle to KiCad format */ private convertCircle; /** * Convert EasyEDA ellipse to KiCad format (approximated as circle if rx≈ry) * KiCad symbols don't support true ellipses, so we use a circle with average radius */ private convertEllipse; /** * Convert EasyEDA polyline to KiCad format */ private convertPolyline; /** * Convert EasyEDA polygon to KiCad format (closed, filled polyline) */ private convertPolygon; /** * Convert EasyEDA arc to KiCad format * Uses SVG arc to center parameterization conversion */ private convertArc; /** * Convert EasyEDA SVG path to KiCad polyline * Supports M (move), L (line), Z (close) commands */ private convertPath; /** * Convert EasyEDA text to KiCad format * Renders decorative text labels inside the symbol */ private convertText; /** * Parse SVG path string (M/L/Z commands) to array of points * Format: "M x1,y1 L x2,y2 L x3,y3 Z" or "M x1 y1 L x2 y2 ..." */ private parseSvgPath; /** * Parse space-separated point string to array of {x, y} */ private parsePoints; /** * Generate a pin using EasyEDA coordinates and rotation * * EasyEDA: pin.x/y is the WIRE connection point (junction) * rotation points FROM wire TO body * KiCad: pin position is the WIRE connection point * rotation points FROM wire TO body * * So we just need coordinate conversion with Y-flip! */ private generateShapePin; /** * Map EasyEDA pin rotation to KiCad rotation * * EasyEDA: rotation indicates direction pin EXTENDS from wire (away from body) * KiCad: rotation indicates direction pin POINTS (from wire toward body) * * So we need to flip by 180°, then account for Y-axis flip: * - EasyEDA 0 (extends right, body on left) -> KiCad 180 (points left toward body) * - EasyEDA 180 (extends left, body on right) -> KiCad 0 (points right toward body) * - EasyEDA 90 (extends down, body on top) -> KiCad 90 (points up toward body, Y-flipped) * - EasyEDA 270 (extends up, body on bottom) -> KiCad 270 (points down toward body, Y-flipped) */ private mapPinRotation; /** * Get KiCad pin style from EasyEDA pin indicators */ private getPinStyle; /** * Calculate DIP-style IC layout from EasyEDA pins * Matches CDFER layout: wide body, pins extending from edges */ private calculateICLayout; /** * Generate IC body rectangle and pins in single _0_1 unit (CDFER style) */ private generateICGraphics; /** * Generate empty IC pins unit (pins are in _0_1 for CDFER compatibility) */ private generateICPins; /** * Create a new library file with multiple symbols */ createLibrary(components: EasyEDAComponentData[]): string; /** * Append a symbol to an existing library file content * Returns the updated library content */ appendToLibrary(existingLibraryContent: string, component: EasyEDAComponentData, options?: SymbolConversionOptions): string; /** * Check if a symbol already exists in a library */ symbolExistsInLibrary(libraryContent: string, componentName: string): boolean; /** * Replace an existing symbol in a library with a new version * If the symbol doesn't exist, it will be appended */ replaceInLibrary(existingLibraryContent: string, component: EasyEDAComponentData, options?: SymbolConversionOptions): string; /** * Get the sanitized symbol name for a component */ getSymbolName(component: EasyEDAComponentData): string; /** * Generate file header */ private generateHeader; /** * Generate symbol start - NO library prefix in symbol name */ private generateSymbolStart; /** * Generate KiCad property entries in KiCad 9 format */ private generateProperties; /** * Calculate bounding box from pins (for IC/complex components) * Uses improved padding for better visual appearance */ private calculateBoundingBox; /** * Generate _0_1 unit with graphical elements (rectangle body) * Uses IC_MIN_BODY_SIZE for minimum dimensions */ private generateGraphicsUnit; /** * Generate _1_1 unit with pins */ private generatePinsUnit; /** * Generate a single pin entry in KiCad 9 format * Uses IC_PIN_LENGTH for better readability with complex components */ private generatePin; /** * Generate symbol end (closes the symbol, NOT the library) */ private generateSymbolEnd; /** * Generate properties for template-based symbols */ private generateTemplateProperties; /** * Generate graphics unit for template-based symbols */ private generateTemplateGraphics; /** * Generate pins for template-based symbols (2-pin vertical layout) */ private generateTemplatePins; /** * Map EasyEDA pin type to KiCad pin type */ private mapPinType; /** * Calculate pin rotation based on position (points inward toward center) */ private calculatePinRotation; /** * Sanitize component name for KiCad (no special chars except underscore/hyphen) */ private sanitizeName; /** * Sanitize pin name (escape quotes) */ private sanitizePinName; /** * Sanitize general text for properties */ private sanitizeText; } export declare const symbolConverter: SymbolConverter; //# sourceMappingURL=symbol.d.ts.map