@@ -59,7 +59,7 @@ public HSL(int h, int s, int l) {
5959 public RGB toRGB () {
6060 double r = 0 , g = 0 , b = 0 ;
6161 double temp1 , temp2 ;
62- double H = h / 239f ; // h / 360.0;
62+ double H = h / 240f ; // h / 360.0;
6363 double S = s / 240f ; // s / 100.0;
6464 double L = l / 240f ; // l / 100.0;
6565 if (L == 0 ) {
@@ -138,7 +138,7 @@ else if ( var_B == var_Max )
138138 if ( H < 0 ) H += 1 ;
139139 if ( H > 1 ) H -= 1 ;
140140 }
141- h = (int )(239 *H ); // (int)(360*H);
141+ h = (int )(240 *H ); // (int)(360*H);
142142 s = (int )(S *240 ); // (int)(S*100);
143143 l = (int )(L *240 ); // (int)(L*100);
144144 }
@@ -555,7 +555,7 @@ public void run() {
555555 int r = constrain (rText , 255 );
556556 int g = constrain (gText , 255 );
557557 int b = constrain (bText , 255 );
558- rgb = new RGB (r , g , b );
558+ lastSelectedColor = rgb = new RGB (r , g , b );
559559 dialogReturn = rgb ;
560560 dialogShell .close ();
561561 }
@@ -597,13 +597,12 @@ public void run() {
597597 String [] matrix = colorMatrix ;
598598 /**
599599 * @j2sNative
600- * rgbColor = colorMap[colorMatrix [i]];
600+ * rgbColor = colorMap[matrix [i]];
601601 */ {}
602+ HSL hsl = new HSL (0 , 0 , 0 );
603+ hsl .fromRGB (new RGB (rgbColor [0 ], rgbColor [1 ], rgbColor [2 ]));
604+ updateFromHSL (hsl .h , hsl .s , hsl .l );
602605 updateFromRGB (rgbColor [0 ], rgbColor [1 ], rgbColor [2 ]);
603- int h = constrain (hText , 239 );
604- int s = constrain (sText , 240 );
605- int l = constrain (lText , 240 );
606- updateFromHSL (h , s , l );
607606 switchColorBox (i );
608607 }
609608 };
@@ -614,15 +613,13 @@ public void run() {
614613 public void run () {
615614 RGB rgb = customColors [index ];
616615 if (rgb == null ) {
617- updateFromRGB (255 , 255 , 255 );
618- } else {
619- updateFromRGB (rgb .red , rgb .green , rgb .blue );
616+ rgb = new RGB (255 , 255 , 255 );
620617 }
621- int h = constrain (hText , 239 );
622- int s = constrain (sText , 240 );
623- int l = constrain (lText , 240 );
624- updateFromHSL (h , s , l );
618+ HSL hsl = new HSL (0 , 0 , 0 );
619+ hsl .fromRGB (rgb );
620+ updateFromHSL (hsl .h , hsl .s , hsl .l );
625621 selectedCustomIndex = index ;
622+ updateFromRGB (rgb .red , rgb .green , rgb .blue );
626623 switchColorBox (index + 48 );
627624 }
628625 };
0 commit comments