/** * Fretboard class - Main class for rendering guitar fretboards as SVG * * The Fretboard class is the primary entry point for the Fretly library. * It handles the creation and rendering of guitar/bass fretboards with configurable * options including string count, fret count, orientation, and visual styling. * * @example * ```typescript * // Create a standard 6-string guitar fretboard * const fretboard = new Fretboard(); * const svg = fretboard.render(); * document.body.appendChild(svg); * * // Create a 4-string bass in vertical orientation * const bassFretboard = new Fretboard({ * stringCount: 4, * fretCount: 24, * orientation: 'vertical' * }); * ``` */ import type { FretboardOptions, Position, PNGExportOptions } from './types'; import { Marker } from './Marker'; import { Fingering } from './Fingering'; export type { FretboardOptions }; /** * Main Fretboard class for rendering guitar necks as SVG * * Provides methods for creating, configuring, and rendering fretboards, * as well as querying positions for strings, frets, and markers. */ export declare class Fretboard { /** Configuration options */ private readonly options; /** SVG renderer instance responsible for creating SVG elements */ private readonly renderer; /** Cached string objects representing the guitar/bass strings */ private strings; /** Cached fret objects representing the fret wires */ private frets; /** Cached inlay objects for fret position markers */ private inlays; /** Custom marker objects added by users */ private markers; /** Fingering markers added by users */ private fingerings; /** Cached SVG element to avoid re-rendering */ private svgCache?; /** * Creates a new Fretboard instance * * @param options - Partial configuration options. Missing values use library defaults. * @throws RangeError if any option value is outside valid ranges */ constructor(options?: Partial); /** * Initializes strings, frets, and inlays based on configuration */ private initializeGeometry; /** * Creates string objects with positions */ private initializeStrings; /** * Creates fret objects with positions * Note: We create fretCount + 1 frets to form a complete rectangle * (e.g., 12 frets = 13 fret lines including start and end) */ private initializeFrets; /** * Creates inlay objects at specified positions */ private initializeInlays; /** * Renders the fretboard as an SVG element * * Creates and returns an SVG representation of the fretboard based on the current * configuration. Results are cached for performance, so subsequent calls return * the same SVG element until the fretboard is modified. * * @returns SVGSVGElement - The rendered fretboard as an SVG element * * @example * ```typescript * const fretboard = new Fretboard(); * const svg = fretboard.render(); * document.getElementById('container').appendChild(svg); * ``` */ render(): SVGSVGElement; /** * Exports the rendered fretboard as a PNG Blob * * @param options - PNG export options (scale factor, quality) * @returns Promise resolving to PNG Blob */ toPNGBlob(options?: PNGExportOptions): Promise; /** * Exports the rendered fretboard as a PNG Data URL string * * @param options - PNG export options (scale factor, quality) * @returns Promise resolving to PNG Data URL string */ toPNGDataURL(options?: PNGExportOptions): Promise; /** * Triggers a browser file download of the rendered fretboard as a PNG file * * @param filename - Destination filename for the download (default: 'fretboard.png') * @param options - PNG export options (scale factor, quality) */ downloadPNG(filename?: string, options?: PNGExportOptions): Promise; /** * Returns the coordinates for a specific fret * * @param fretIndex - The 1-based index of the fret (1 to fretCount) * @returns Position - The {x, y} coordinates of the fret * @throws RangeError if fretIndex is outside valid range * * @example * ```typescript * const fretboard = new Fretboard(); * const position = fretboard.getFretPosition(5); // 5th fret position * ``` */ getFretPosition(fretIndex: number): Position; /** * Returns the coordinates for a specific string * * @param stringIndex - The 0-based index of the string (0 to stringCount-1) * @returns Position - The {x, y} coordinates of the string * @throws RangeError if stringIndex is outside valid range * * @example * ```typescript * const fretboard = new Fretboard(); * const position = fretboard.getStringPosition(0); // High E string position * ``` */ getStringPosition(stringIndex: number): Position; /** * Returns the coordinates for placing a marker at a specific fret/string intersection * * @param fretIndex - The 1-based index of the fret (1 to fretCount) * @param stringIndex - The 0-based index of the string (0 to stringCount-1) * @returns Position - The {x, y} coordinates for placing a marker * @throws RangeError if fretIndex or stringIndex are outside valid ranges * * @example * ```typescript * const fretboard = new Fretboard(); * const position = fretboard.getMarkerPosition(5, 2); // 5th fret, 3rd string * ``` */ getMarkerPosition(fretIndex: number, stringIndex: number): Position; /** * Adds a custom marker to the fretboard * * Creates a marker at the specified fret/string position and adds it to the fretboard. * The marker will be rendered when the fretboard is next rendered. * * @param fretIndex - The 1-based index of the fret (1 to fretCount) * @param stringIndex - The 0-based index of the string (0 to stringCount-1) * @param options - Optional marker styling options (color, size, etc.) * @returns Marker - The created marker instance * @throws RangeError if fretIndex or stringIndex are outside valid ranges * * @example * ```typescript * const fretboard = new Fretboard(); * const marker = fretboard.addMarker(5, 2, { * color: 'red', * size: 8 * }); * ``` */ addMarker(fretIndex: number, stringIndex: number, options?: Partial): Marker; /** * Removes a marker by ID * * @param id - The unique identifier of the marker to remove * @returns boolean - true if marker was found and removed, false otherwise * * @example * ```typescript * const marker = fretboard.addMarker(5, 2); * fretboard.removeMarker(marker.id); * ``` */ removeMarker(id: string): boolean; /** * Clears all markers from the fretboard * * @example * ```typescript * fretboard.clearMarkers(); * ``` */ clearMarkers(): void; /** * Returns all markers on the fretboard * * @returns Marker[] - Array of all marker instances * * @example * ```typescript * const markers = fretboard.getMarkers(); * markers.forEach(marker => console.log(marker.fretIndex, marker.stringIndex)); * ``` */ getMarkers(): Marker[]; /** * Returns all fingering markers on the fretboard * * @returns Fingering[] - Array of all fingering instances */ getFingerings(): Fingering[]; /** * Returns the current configuration options * * @returns Required - Complete configuration with all defaults applied * * @example * ```typescript * const options = fretboard.getOptions(); * console.log(options.fretCount, options.stringCount); * ``` */ getOptions(): Required; /** * Returns the starting fret configured for this fretboard */ get startFret(): number; /** * Returns the number of frets configured for this fretboard * * @example * ```typescript * const fretboard = new Fretboard({ fretCount: 24 }); * console.log(fretboard.fretCount); // 24 * ``` */ get fretCount(): number; /** * Returns the number of strings configured for this fretboard * * @example * ```typescript * const fretboard = new Fretboard({ stringCount: 7 }); * console.log(fretboard.stringCount); // 7 * ``` */ get stringCount(): number; /** * Returns the current orientation of the fretboard * * @example * ```typescript * const fretboard = new Fretboard({ orientation: 'vertical' }); * console.log(fretboard.orientation); // 'vertical' * ``` */ get orientation(): 'horizontal' | 'vertical'; /** * Invalidates the SVG cache * * Call this method after making external modifications to force a re-render * of the fretboard SVG on the next call to render(). * * @example * ```typescript * const fretboard = new Fretboard(); * // After modifying something externally * fretboard.invalidateCache(); * const freshSvg = fretboard.render(); * ``` */ invalidateCache(): void; } //# sourceMappingURL=Fretboard.d.ts.map