I'm trying to figure out a way to generate a gradient that should look like this: 
However, I don't know how to combine multiple colors (red, blue, and green) at once. Here is how my code looks like at the moment:
color red;
color blue;
color green;
void setup() {
size(255, 255);
red = color(255,0,0);
blue = color(0,0,255);
green = color(0,255,0);
for(int x = 0; x < width; x++) {
float n = map(x, 0, width, 0, 1);
color newc = lerpColor(blue, red, n);
stroke(newc);
line(0, x, height, x);
}
}
void draw() {
}
As you can see, the color green is currently not being used as I can't find a way to interpolate these colors while retaining the red and blue gradient. I'm a beginner in Processing so I would appreciate some help regarding this. How should I write my code?