I am drawing rectangles in Android using the graphics canvas, color, and paint classes. If I have the rectangles stored in an array with a color for each, how would I have the colors gradient from one end to the other? I've been attempting to modify the rgb values using Color.red(colorInt) etc. but I'm getting some strange results.
Edit: Each rectangle itself does not have a gradient. I need each to be a solid color. I've tried multiplying each color component by a weight based on where in the array a rectangle is but it's ineffective.
Here is some of the code I tried.
if(lt != null && rt != null)
{
int r = (int) ((Color.red(lt.getColor()) * (1.0 - weight)) - (Color.red(rt.getColor()) * weight));
int g = (int) ((Color.green(lt.getColor()) * (1.0 - weight)) - (Color.green(rt.getColor()) * weight));
int b = (int) ((Color.blue(lt.getColor()) * (1.0 - weight)) - (Color.blue(rt.getColor()) * weight));
color = Color.argb(ALPHA, r, g, b);
}