So I need to blend 2 colors with different alpha values. Either color can have an alpha color of 0-255. Here's the algorithm I am using now and it doesn't work. If the alpha is above 1 for either color then the whole color turns solid. On a scale of 0-255 1 should be almost entirely transparent. What do I need to change in order to achieve this?
public void blend(Color color1, Color color2, double ratio) {
float r = (float) ratio;
float ir = (float) 1.0 - r;
float[] rgb1 = new float[3];
float[] rgb2 = new float[3];
color1.getColorComponents(rgb1);
color2.getColorComponents(rgb2);
Color color = new Color(rgb1[0] * r + rgb2[0] * ir, rgb1[1] * r + rgb2[1] * ir, rgb1[2] * r + rgb2[2] * ir);
this.color = color;
}