15
15
*/
16
16
package org .beryx .textio .jline ;
17
17
18
- import javafx . scene . paint .Color ;
18
+ import java . awt .Color ;
19
19
import jline .console .ConsoleReader ;
20
20
import jline .console .CursorBuffer ;
21
21
import jline .console .UserInterruptException ;
22
+ import org .beryx .awt .color .ColorFactory ;
22
23
import org .beryx .textio .*;
23
24
import org .slf4j .Logger ;
24
25
import org .slf4j .LoggerFactory ;
@@ -123,12 +124,12 @@ private static String getStandardColorCode(Color color) {
123
124
}
124
125
125
126
private static double getColorDistance (Color col1 , Color col2 ) {
126
- double r1 = col1 .getRed ();
127
- double g1 = col1 .getGreen ();
128
- double b1 = col1 .getBlue ();
129
- double r2 = col2 .getRed ();
130
- double g2 = col2 .getGreen ();
131
- double b2 = col2 .getBlue ();
127
+ double r1 = col1 .getRed () / 255.0 ;
128
+ double g1 = col1 .getGreen () / 255.0 ;
129
+ double b1 = col1 .getBlue () / 255.0 ;
130
+ double r2 = col2 .getRed () / 255.0 ;
131
+ double g2 = col2 .getGreen () / 255.0 ;
132
+ double b2 = col2 .getBlue () / 255.0 ;
132
133
133
134
double rmean = (r1 + r2 ) / 2 ;
134
135
double dr = r1 - r2 ;
@@ -139,17 +140,17 @@ private static double getColorDistance(Color col1, Color col2) {
139
140
}
140
141
141
142
private static String getIndexedColorCode (Color color ) {
142
- double r = 255 * color .getRed ();
143
- double g = 255 * color .getGreen ();
144
- double b = 255 * color .getBlue ();
143
+ double r = color .getRed ();
144
+ double g = color .getGreen ();
145
+ double b = color .getBlue ();
145
146
int val = 16 + 36 * mapTo6 (r ) + 6 * mapTo6 (g ) + mapTo6 (b );
146
147
return "8;5;" + val ;
147
148
}
148
149
149
150
private static String getRGBColorCode (Color color ) {
150
- int r = ( int )( 255 * color .getRed () );
151
- int g = ( int )( 255 * color .getGreen () );
152
- int b = ( int )( 255 * color .getBlue () );
151
+ int r = color .getRed ();
152
+ int g = color .getGreen ();
153
+ int b = color .getBlue ();
153
154
return "8;2;" + r + ";" + g + ";" + b ;
154
155
}
155
156
@@ -164,7 +165,7 @@ public Optional<String> getColorCode(String colorName) {
164
165
if (code >= 0 ) {
165
166
return Optional .of ("" + code );
166
167
}
167
- Color color = Color .web (colorName );
168
+ Color color = ColorFactory .web (colorName );
168
169
return Optional .of (ansiColorMode .getAnsiColorCode (color ));
169
170
} catch (Exception e ) {
170
171
// the error will be logged below
0 commit comments