size(400, 100); background(255); // white background float left_margin = 10; float top_margin = 10; float w = width - left_margin*2; float h = height - top_margin*2; for (int i = 0; i < h; ++i) { float ratio = i/h; float red = 256 * ratio; float green = 256 * (1-ratio); float blue = 0; stroke( red, green, blue ); line(left_margin, top_margin+i, left_margin+w, top_margin+i); }