@@ -1658,62 +1658,6 @@ function LegoWidget() {
16581658 document . addEventListener ( "mouseup" , this . _dragUpHandler ) ;
16591659 } ;
16601660
1661- /**
1662- * Converts RGB values to a named color category with improved accuracy.
1663- * @private
1664- */
1665- this . _getColorFamily = function ( r , g , b ) {
1666- const hsl = this . _rgbToHsl ( r , g , b ) ;
1667- const [ hue , saturation , lightness ] = hsl ;
1668-
1669- // Simple and accurate color detection
1670-
1671- // Handle very dark colors first
1672- if ( lightness < 15 ) {
1673- return { name : "black" , hue : hue , saturation : saturation , lightness : lightness } ;
1674- }
1675-
1676- // Handle grayscale colors (low saturation) - keep it simple
1677- if ( saturation < 20 ) {
1678- if ( lightness > 85 )
1679- return { name : "white" , hue : hue , saturation : saturation , lightness : lightness } ;
1680- if ( lightness < 25 )
1681- return { name : "black" , hue : hue , saturation : saturation , lightness : lightness } ;
1682- return { name : "gray" , hue : hue , saturation : saturation , lightness : lightness } ;
1683- }
1684-
1685- // Improved hue-based detection with clear boundaries to prevent orange/purple confusion
1686- let colorName = "unknown" ;
1687-
1688- if ( hue >= 345 || hue < 15 ) {
1689- colorName = "red" ;
1690- } else if ( hue >= 15 && hue < 45 ) {
1691- // Orange range - key fix for orange/purple confusion
1692- colorName = "orange" ;
1693- } else if ( hue >= 45 && hue < 75 ) {
1694- colorName = "yellow" ;
1695- } else if ( hue >= 75 && hue < 165 ) {
1696- colorName = "green" ;
1697- } else if ( hue >= 165 && hue < 195 ) {
1698- colorName = "cyan" ;
1699- } else if ( hue >= 195 && hue < 255 ) {
1700- colorName = "blue" ;
1701- } else if ( hue >= 255 && hue < 285 ) {
1702- // Purple range - separated clearly from orange
1703- colorName = "purple" ;
1704- } else if ( hue >= 285 && hue < 315 ) {
1705- colorName = "magenta" ;
1706- } else if ( hue >= 315 && hue < 345 ) {
1707- colorName = "pink" ;
1708- }
1709-
1710- return {
1711- name : colorName ,
1712- hue : hue ,
1713- saturation : saturation ,
1714- lightness : lightness
1715- } ;
1716- } ;
17171661 /**
17181662 * Gets color family from HSL values
17191663 * @private
@@ -1745,30 +1689,6 @@ function LegoWidget() {
17451689 return { name : "unknown" , hue : h } ;
17461690 } ;
17471691
1748- /**
1749- * Gets color family by name with simple mapping.
1750- * @private
1751- * @param {string } colorName - The color name
1752- * @returns {object } Color family object
1753- */
1754- this . _getColorFamilyByName = function ( colorName ) {
1755- const colorFamilies = {
1756- red : { name : "red" , hue : 0 , saturation : 80 , lightness : 50 } ,
1757- orange : { name : "orange" , hue : 30 , saturation : 80 , lightness : 50 } ,
1758- yellow : { name : "yellow" , hue : 60 , saturation : 80 , lightness : 50 } ,
1759- green : { name : "green" , hue : 120 , saturation : 80 , lightness : 50 } ,
1760- cyan : { name : "cyan" , hue : 180 , saturation : 80 , lightness : 50 } ,
1761- blue : { name : "blue" , hue : 240 , saturation : 80 , lightness : 50 } ,
1762- purple : { name : "purple" , hue : 270 , saturation : 80 , lightness : 50 } ,
1763- magenta : { name : "magenta" , hue : 300 , saturation : 80 , lightness : 50 } ,
1764- pink : { name : "pink" , hue : 330 , saturation : 70 , lightness : 75 } ,
1765- white : { name : "white" , hue : 0 , saturation : 0 , lightness : 95 } ,
1766- gray : { name : "gray" , hue : 0 , saturation : 5 , lightness : 50 } ,
1767- black : { name : "black" , hue : 0 , saturation : 0 , lightness : 5 }
1768- } ;
1769- return colorFamilies [ colorName ] || null ;
1770- } ;
1771-
17721692 /**
17731693 * Converts RGB to HSL.
17741694 * @private
0 commit comments