@@ -5702,13 +5702,16 @@ public int lerpColor(int c1, int c2, float amt) {
5702
5702
5703
5703
static float [] lerpColorHSB1 ;
5704
5704
static float [] lerpColorHSB2 ;
5705
- static float [] lerpColorHSB3 ;
5705
+ static float [] lerpColorHSB3 ;
5706
5706
5707
5707
/**
5708
5708
* Interpolate between two colors. Like lerp(), but for the
5709
5709
* individual color components of a color supplied as an int value.
5710
5710
*/
5711
5711
static public int lerpColor (int c1 , int c2 , float amt , int mode ) {
5712
+ if (amt < 0 ) amt = 0 ;
5713
+ if (amt > 1 ) amt = 1 ;
5714
+
5712
5715
if (mode == RGB ) {
5713
5716
float a1 = ((c1 >> 24 ) & 0xff );
5714
5717
float r1 = (c1 >> 16 ) & 0xff ;
@@ -5719,10 +5722,10 @@ static public int lerpColor(int c1, int c2, float amt, int mode) {
5719
5722
float g2 = (c2 >> 8 ) & 0xff ;
5720
5723
float b2 = c2 & 0xff ;
5721
5724
5722
- return ((( int ) (a1 + (a2 -a1 )*amt ) << 24 ) |
5723
- (( int ) (r1 + (r2 -r1 )*amt ) << 16 ) |
5724
- (( int ) (g1 + (g2 -g1 )*amt ) << 8 ) |
5725
- (( int ) (b1 + (b2 -b1 )*amt )));
5725
+ return ((PApplet . round (a1 + (a2 -a1 )*amt ) << 24 ) |
5726
+ (PApplet . round (r1 + (r2 -r1 )*amt ) << 16 ) |
5727
+ (PApplet . round (g1 + (g2 -g1 )*amt ) << 8 ) |
5728
+ (PApplet . round (b1 + (b2 -b1 )*amt )));
5726
5729
5727
5730
} else if (mode == HSB ) {
5728
5731
if (lerpColorHSB1 == null ) {
@@ -5733,7 +5736,7 @@ static public int lerpColor(int c1, int c2, float amt, int mode) {
5733
5736
5734
5737
float a1 = (c1 >> 24 ) & 0xff ;
5735
5738
float a2 = (c2 >> 24 ) & 0xff ;
5736
- int alfa = (( int ) (a1 + (a2 -a1 )*amt )) << 24 ;
5739
+ int alfa = (PApplet . round (a1 + (a2 -a1 )*amt )) << 24 ;
5737
5740
5738
5741
Color .RGBToHSV ((c1 >> 16 ) & 0xff , (c1 >> 8 ) & 0xff , c1 & 0xff ,
5739
5742
lerpColorHSB1 );
@@ -5765,23 +5768,21 @@ static public int lerpColor(int c1, int c2, float amt, int mode) {
5765
5768
}
5766
5769
float ho = (PApplet.lerp(lerpColorHSB1[0], lerpColorHSB2[0], amt)) % 1.0f;
5767
5770
*/
5771
+ // float ho = PApplet.lerp(lerpColorHSB1[0], lerpColorHSB2[0], amt);
5772
+ // float so = PApplet.lerp(lerpColorHSB1[1], lerpColorHSB2[1], amt);
5773
+ // float bo = PApplet.lerp(lerpColorHSB1[2], lerpColorHSB2[2], amt);
5768
5774
5769
- // float ho = PActivity.lerp(lerpColorHSB1[0], lerpColorHSB2[0], amt);
5770
- // float so = PActivity.lerp(lerpColorHSB1[1], lerpColorHSB2[1], amt);
5771
- // float bo = PActivity.lerp(lerpColorHSB1[2], lerpColorHSB2[2], amt);
5772
- // return alfa | (Color.HSVtoRGB(ho, so, bo) & 0xFFFFFF);
5773
- // return Color.HSVToColor(alfa, new float[] { ho, so, bo });
5775
+ // return alfa | (Color.RGBToHSV(ho, so, bo) & 0xFFFFFF);
5774
5776
5775
5777
lerpColorHSB3 [0 ] = PApplet .lerp (lerpColorHSB1 [0 ], lerpColorHSB2 [0 ], amt );
5776
5778
lerpColorHSB3 [1 ] = PApplet .lerp (lerpColorHSB1 [1 ], lerpColorHSB2 [1 ], amt );
5777
5779
lerpColorHSB3 [2 ] = PApplet .lerp (lerpColorHSB1 [2 ], lerpColorHSB2 [2 ], amt );
5778
- return Color .HSVToColor (alfa , lerpColorHSB3 );
5780
+ return Color .HSVToColor (alfa , lerpColorHSB3 );
5779
5781
}
5780
5782
return 0 ;
5781
5783
}
5782
5784
5783
5785
5784
-
5785
5786
//////////////////////////////////////////////////////////////
5786
5787
5787
5788
// BEGINRAW/ENDRAW
0 commit comments