@@ -398,9 +398,9 @@ public static int getArgbFromString(String strColor) {
398398 .length () - 1 ), "," );
399399 if (tokens .length != 3 )
400400 return 0 ;
401- float red = PT .parseFloat (tokens [0 ]);
402- float grn = PT .parseFloat (tokens [1 ]);
403- float blu = PT .parseFloat (tokens [2 ]);
401+ double red = PT .parseDouble (tokens [0 ]);
402+ double grn = PT .parseDouble (tokens [1 ]);
403+ double blu = PT .parseDouble (tokens [2 ]);
404404 return colorTriadToFFRGB (red , grn , blu );
405405 }
406406 switch (len ) {
@@ -429,7 +429,7 @@ public static int getArgbFromString(String strColor) {
429429 return (boxedArgb == null ? 0 : boxedArgb .intValue ());
430430 }
431431
432- public static int colorTriadToFFRGB (float x , float y , float z ) {
432+ public static int colorTriadToFFRGB (double x , double y , double z ) {
433433 if (x <= 1 && y <= 1 && z <= 1 ) {
434434 if (x > 0 )
435435 x = x * 256 - 1 ;
@@ -445,13 +445,13 @@ public static int rgb(int red, int grn, int blu) {
445445 return 0xFF000000 | (red << 16 ) | (grn << 8 ) | blu ;
446446 }
447447
448- public final static P3 colorPtFromString (String colorName ) {
448+ public final static P3d colorPtFromString (String colorName ) {
449449 return colorPtFromInt (getArgbFromString (colorName ), null );
450450 }
451451
452- public final static P3 colorPtFromInt (int color , P3 pt ) {
452+ public final static P3d colorPtFromInt (int color , P3d pt ) {
453453 if (pt == null )
454- pt = new P3 ();
454+ pt = new P3d ();
455455 pt .set ((color >> 16 ) & 0xFF , (color >> 8 ) & 0xFF , color & 0xFF );
456456 return pt ;
457457 }
@@ -460,7 +460,7 @@ public static int colorPtToFFRGB(T3 pt) {
460460 return colorTriadToFFRGB (pt .x , pt .y , pt .z );
461461 }
462462
463- public static void toRGB3f (int c , float [] f ) {
463+ public static void toRGB3f (int c , double [] f ) {
464464 f [0 ] = ((c >> 16 ) & 0xFF ) / 255f ; // red
465465 f [1 ] = ((c >> 8 ) & 0xFF ) / 255f ;
466466 f [2 ] = (c & 0xFF ) / 255f ;
@@ -492,62 +492,62 @@ public static int toFFGGGfromRGB(int rgb) {
492492 * set to false when just using this for
493493 * for RGB -- HSL -- HSL' -- RGB' conversion
494494 *
495- * @return the HSL as P3 range 360 100 100
495+ * @return the HSL as P3d range 360 100 100
496496 * @author hansonr
497497 */
498498
499- public static P3 rgbToHSL (P3 rgb , boolean doRound ) {
499+ public static P3d rgbToHSL (P3d rgb , boolean doRound ) {
500500 // adapted from http://tips4java.wordpress.com/2009/07/05/hsl-color/
501501 // see http://en.wikipedia.org/wiki/HSL_color_space
502- float r = rgb .x / 255 ;
503- float g = rgb .y / 255 ;
504- float b = rgb .z / 255 ;
505- float min = Math .min (r , Math .min (g , b ));
506- float max = Math .max (r , Math .max (g , b ));
502+ double r = rgb .x / 255 ;
503+ double g = rgb .y / 255 ;
504+ double b = rgb .z / 255 ;
505+ double min = Math .min (r , Math .min (g , b ));
506+ double max = Math .max (r , Math .max (g , b ));
507507
508508 // lightness is just p * 50
509509
510- float p = (max + min );
511- float q = (max - min );
510+ double p = (max + min );
511+ double q = (max - min );
512512
513- float h = (60 * ((q == 0 ? 0 : max == r ? ((g - b ) / q + 6 )
513+ double h = (60 * ((q == 0 ? 0 : max == r ? ((g - b ) / q + 6 )
514514 : max == g ? (b - r ) / q + 2 : (r - g ) / q + 4 ))) % 360 ;
515515
516- float s = q / (q == 0 ? 1 : p <= 1 ? p : 2 - p );
516+ double s = q / (q == 0 ? 1 : p <= 1 ? p : 2 - p );
517517
518518 // we round to tenths for HSL so that we can return enough
519519 // precision to get back 1-255 in RGB
520- return (doRound ? P3 .new3 (Math .round (h *10 )/10f , Math .round (s * 1000 )/10f ,
521- Math .round (p * 500 )/10f ) : P3 .new3 (h , s * 100 , p * 50 ));
520+ return (doRound ? P3d .new3 (Math .round (h *10 )/10f , Math .round (s * 1000 )/10f ,
521+ Math .round (p * 500 )/10f ) : P3d .new3 (h , s * 100 , p * 50 ));
522522 }
523523
524524 /**
525525 * Convert HSL (hue/saturation/luninance) values to RGB
526526 *
527527 * @param hsl in the range 360, 100, 100
528- * @return the RGB as P3 range 0 to 255
528+ * @return the RGB as P3d range 0 to 255
529529 * @author hansonr
530530 */
531- public static P3 hslToRGB (P3 hsl ) {
531+ public static P3d hslToRGB (P3d hsl ) {
532532 // adapted from http://tips4java.wordpress.com/2009/07/05/hsl-color/
533533 // see http://en.wikipedia.org/wiki/HSL_color_space
534534
535535 // highly condensed
536536
537- float h = Math .max (0 , Math .min (360 , hsl .x )) / 60 ;
538- float s = Math .max (0 , Math .min (100 , hsl .y )) / 100 ;
539- float l = Math .max (0 , Math .min (100 , hsl .z )) / 100 ;
537+ double h = Math .max (0 , Math .min (360 , hsl .x )) / 60 ;
538+ double s = Math .max (0 , Math .min (100 , hsl .y )) / 100 ;
539+ double l = Math .max (0 , Math .min (100 , hsl .z )) / 100 ;
540540
541- float p = l - (l < 0.5 ? l : 1 - l ) * s ;
542- float q = 2 * (l - p );
541+ double p = l - (l < 0.5 ? l : 1 - l ) * s ;
542+ double q = 2 * (l - p );
543543
544- float r = toRGB (p , q , h + 2 );
545- float g = toRGB (p , q , h );
546- float b = toRGB (p , q , h - 2 );
547- return P3 .new3 (Math .round (r * 255 ), Math .round (g * 255 ), Math .round (b * 255 ));
544+ double r = toRGB (p , q , h + 2 );
545+ double g = toRGB (p , q , h );
546+ double b = toRGB (p , q , h - 2 );
547+ return P3d .new3 (Math .round (r * 255 ), Math .round (g * 255 ), Math .round (b * 255 ));
548548 }
549549
550- private static float toRGB (float p , float q , float h ) {
550+ private static double toRGB (double p , double q , double h ) {
551551 return ((h = (h + (h < 0 ? 6 : h > 6 ? -6 : 0 ))) < 1 ? p + q * h
552552 : h < 3 ? p + q : h < 4 ? p + q * (4 - h ) : p );
553553 }
0 commit comments