size(400,400); for (int x=0; x < width; x++) { float percent = 1.0 * x / (width-1); // force floating-point arithmetic stroke(percent * 255, 0, (1-percent) * 255); line(x, 0, x, height); }