We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › 3D bezier curve with gradient fill
Page Index Toggle Pages: 1
3D bezier curve with gradient fill (Read 2371 times)
3D bezier curve with gradient fill
Jun 14th, 2010, 10:45am
 
Hello everyone, I'd like to draw a bezier curve on the space with gradient fill, as in starting with a color and ending with another. It's on the context of my previous questions (see http://processing.org/discourse/yabb2/num_1264522077__.html

So, if I wanted this on 2D I would iterate over bezierPoint() changing the colors in each step, but there's no bezierPoint() for 3D coordinates.

I've tried with a gradient texture from another example, but didn't work well; fact is I don't really know much about textures yet.

So... can you guys give me any pointers

Thank you!

Edit: It's actually a gradient stroke, not a gradient fill.
Re: 3D bezier curve with gradient fill
Reply #1 - Jun 14th, 2010, 10:57am
 
Sorry, I was wrong, bezierPoint() actually works for 3D. I just worked out what I needed. The following is an example in case anyone else needs it:
Code:

   color from = color(255, 0, 0);
   color to = color(0, 255, 0);
   int steps = 10;
   beginShape();
   for (int j = 0; j <= steps; j++) {
     float t = j / float(steps);
     stroke(lerpColor(from, to, t));
     float x = bezierPoint(x1, cx1, cx2, x2, t);
     float y = bezierPoint(y1, cy1, cy2, y2, t);
     float z = bezierPoint(z1, cz1, cz2, z2, t);      
     vertex(x, y, z);
   }
   endShape();

Page Index Toggle Pages: 1