POV-Ray : Newsgroups : povray.newusers : How do I add color to "sphere_sweep"? : Re: How do I add color to "sphere_sweep"? Server Time
6 Oct 2024 02:20:48 EDT (-0400)
  Re: How do I add color to "sphere_sweep"?  
From: Chris B
Date: 12 Aug 2009 04:34:40
Message: <4a827ea0@news.povray.org>
"Alex" <ale### [at] hotmailcom> wrote in message 
news:web.4a82745d1c23c4f8db8ca50@news.povray.org...
> Hi,
>
> How can I add 'true-indexed' RGB color to each point along a 
> "sphere_sweep"
> object? In other words, if this "sphere_sweep" object is defined by N 
> points, I
> would like to be able to specify N RGB colors.
>
> Many thanks in advance for helping me out!
>
> Cheers,
> Alex
>

I don't think there's an easy way of doing exactly that. OTOH you can do 
something equivalent using splines and a #while loop quite easily. The 
spline example below is taken straight from the spline section in the help 
and illustrates using different colors along the length of an object created 
using lots of spheres (in this case about 100). It shouldn't be too 
difficult to adapt that to do something equivalent to what you ask.

camera {location <-1, 1,-1> look_at <0,0,0>}
light_source {<1,10,-1> color rgb 1}

#declare MySpline = spline {
  cubic_spline
  -.25, <0,0,-1>
  0.00, <1,0,0>
  0.25, <0,0,1>
  0.50, <-1,0,0>
  0.75, <0,0,-1>
  1.00, <1,0,0>
  1.25, <0,0,1>
}

#declare ctr = 0;
#while (ctr < 1)
  sphere {
    MySpline(ctr),.25
    pigment { rgb <1-ctr,ctr,0> }
  }
  #declare ctr = ctr + 0.01;
#end


Regards,
Chris B.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.