UNPKG

aura-glass

Version:

A comprehensive glassmorphism design system for React applications with 142+ production-ready components

211 lines 5.13 kB
/** * AuraGlass Smart Color Extraction * AI-powered color extraction from images, videos, and content */ interface ExtractedColor { hex: string; rgb: { r: number; g: number; b: number; }; hsl: { h: number; s: number; l: number; }; lab: { l: number; a: number; b: number; }; weight: number; contrast: number; temperature: 'warm' | 'cool' | 'neutral'; emotion: string; } interface ColorPalette { primary: ExtractedColor; secondary: ExtractedColor; accent: ExtractedColor; dominant: ExtractedColor[]; supporting: ExtractedColor[]; gradients: { primary: string; secondary: string; mesh: string; }; accessibility: { textOnLight: ExtractedColor; textOnDark: ExtractedColor; backgrounds: ExtractedColor[]; }; } interface ColorExtractionOptions { maxColors?: number; quality?: 'fast' | 'balanced' | 'precise'; ignoreWhite?: boolean; ignoreBlack?: boolean; minSaturation?: number; minLightness?: number; maxLightness?: number; clustering?: 'kmeans' | 'median-cut' | 'octree'; generateGradients?: boolean; ensureAccessibility?: boolean; } export declare class SmartColorExtraction { private static instance; private canvas; private ctx; private colorCache; private colorEmotions; private constructor(); static getInstance(): SmartColorExtraction; /** * Extract colors from an image */ extractFromImage(source: HTMLImageElement | string, options?: ColorExtractionOptions): Promise<ColorPalette>; /** * Extract colors from video */ extractFromVideo(video: HTMLVideoElement, options?: ColorExtractionOptions & { frameInterval?: number; }): Promise<ColorPalette>; /** * Extract colors from DOM element */ extractFromElement(element: HTMLElement, options?: ColorExtractionOptions): Promise<ColorPalette>; /** * Load image from URL */ private loadImage; /** * Get optimal canvas size */ private getOptimalSize; /** * Extract colors from image data using specified algorithm */ private extractColorsFromImageData; /** * K-means clustering algorithm */ private kMeansCluster; /** * Simplified median cut clustering */ private medianCutCluster; /** * Simplified octree clustering */ private octreeCluster; /** * Calculate color distance (Euclidean in RGB space) */ private colorDistance; /** * Convert RGB to ExtractedColor with metadata */ private rgbToExtractedColor; /** * Convert RGB to HSL */ private rgbToHsl; /** * Convert RGB to LAB color space */ private rgbToLab; /** * Calculate WCAG contrast ratio */ private getContrastRatio; /** * Get relative luminance */ private getLuminance; /** * Determine color temperature */ private getColorTemperature; /** * Get color emotion */ private getColorEmotion; /** * Generate comprehensive color palette */ private generatePalette; /** * Find accent color that contrasts well with primary */ private findAccentColor; /** * Generate complementary color */ private generateComplementaryColor; /** * Convert HSL to hex */ private hslToHex; /** * Generate mesh gradient */ private generateMeshGradient; /** * Generate accessibility-compliant colors */ private generateAccessibilityColors; /** * Extract colors from DOM styles */ private extractColorsFromStyles; /** * Parse CSS color values */ private parseColorValues; /** * Convert hex to RGB */ private hexToRgb; /** * Merge similar colors and combine their weights */ private mergeColors; /** * Quantize hex color for grouping */ private quantizeHex; /** * Seek video to specific time */ private seekVideo; /** * Get default palette fallback */ private getDefaultPalette; /** * Clear color cache */ clearCache(): void; /** * Get cache statistics */ getCacheStats(): { size: number; keys: string[]; }; } export declare const smartColorExtraction: SmartColorExtraction; export declare function useSmartColorExtraction(): { palette: ColorPalette | null; isExtracting: boolean; error: string | null; extractFromImage: (source: HTMLImageElement | string, options?: ColorExtractionOptions) => Promise<ColorPalette>; extractFromVideo: (video: HTMLVideoElement, options?: ColorExtractionOptions & { frameInterval?: number; }) => Promise<ColorPalette>; extractFromElement: (element: HTMLElement, options?: ColorExtractionOptions) => Promise<ColorPalette>; clearCache: () => void; }; export {}; //# sourceMappingURL=smartColorExtraction.d.ts.map