File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -9,11 +9,18 @@ var base64ImageToRGBArray = require('./lib/base64ImageToRGBArray')
99function compressColor ( rgb ) {
1010 var hex = tinycolor ( rgb ) . toHexString ( )
1111
12- if ( hex [ 1 ] === hex [ 2 ] && hex [ 3 ] === hex [ 4 ] && hex [ 5 ] === hex [ 6 ] ) {
13- return '#' + hex [ 1 ] + hex [ 3 ] + hex [ 4 ]
14- } else {
15- return hex
12+ switch ( hex ) { // based on CSS3 supported color names http://www.w3.org/TR/css3-color/
13+ case '#c0c0c0' : return 'silver' ;
14+ case '#808080' : return 'gray' ;
15+ case '#800000' : return 'maroon' ;
16+ case '#ff0000' : return 'red' ;
17+ case '#800080' : return 'purple' ;
18+ case '#008000' : return 'green' ;
19+ case '#808000' : return 'olive' ;
20+ case '#000080' : return 'navy' ;
21+ case '#008080' : return 'teal' ;
1622 }
23+ return hex [ 1 ] === hex [ 2 ] && hex [ 3 ] === hex [ 4 ] && hex [ 5 ] === hex [ 6 ] ? "#" + hex [ 1 ] + hex [ 3 ] + hex [ 5 ] : hex ;
1724}
1825
1926export const App = React . createClass ( {
You can’t perform that action at this time.
0 commit comments