same answer, there is no way to do it with line().... in this case use the beginShape() endShape() function and use fill() between the vertices. It works with different colors, should probably also work with transparency but also only in P3D, not Java2D render.
Another way would also include beginShape() and endShape() but drawing a quadstrip and you get something like this :
- void setup() {
- size(500, 500);
- smooth();
- }
- void draw() {
- noStroke();
- background(0, 0, 255);
- beginShape(QUAD_STRIP);
- for (int i = 0; i<40;i++) {
- fill(255, 0, 0, 255/40*i);
- vertex(50+10*i, 200);
- vertex(50+10*i, 250);
- }
- endShape();
- }