Skip to content

Commit 4359c1b

Browse files
penguin212ky28059
authored andcommitted
opacity calculations more efficient
1 parent 5ac1548 commit 4359c1b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/java/frc/robot/subsystems/leds/LEDStrip.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ public void addLayer(LEDLayer layer) {
4545
* @return The color of the led layers combined
4646
*/
4747
public Color calcColorWithOpacity(Color baseColor, Color topColor, double opacity){
48-
int r = (int) Math.floor(256 * (((1 - opacity) * baseColor.red) + (opacity * topColor.red)));
49-
int g = (int) Math.floor(256 * (((1 - opacity) * baseColor.green) + (opacity * topColor.green)));
50-
int b = (int) Math.floor(256 * (((1 - opacity) * baseColor.blue) + (opacity * topColor.blue)));
48+
double r = (((1 - opacity) * baseColor.red) + (opacity * topColor.red));
49+
double g = (((1 - opacity) * baseColor.green) + (opacity * topColor.green));
50+
double b = (((1 - opacity) * baseColor.blue) + (opacity * topColor.blue));
5151

5252
return(new Color(r, g, b));
5353
}

0 commit comments

Comments
 (0)