POV-Ray : Newsgroups : povray.general : Random Colour picker for spheres : Re: Random Colour picker for spheres Server Time
14 Aug 2024 05:13:21 EDT (-0400)
  Re: Random Colour picker for spheres  
From: Roland Mas
Date: 23 Feb 1998 17:04:41
Message: <6csrpp$nb9$1@melchior.cuivre.fr.eu.org>
Zack Halbrecht (zac### [at] edenrutgersedu) wrote:
> Hey there everyone, i ve got what seemed to me like a pretty basic problem.
> I have a while loop going and want it to draw a series of spheres.  How can
> i
> get it to pick a random color out of four which i determine.?

I suggest using the rand() function (assuming you're using POV 3) combined
with a switch (too tired now to check the syntax in the docs, but sure it
lays there):

#declare loop_iterator = begin_iterator
#while (iterator < end_iterator)
  #declare A = rand()
  #declare B = rand()

  #switch (A)
    #range (0,0.25)
    #declare cx = colour Orange
    #break
    #range (0.25,0.5)
    #declare cx = colour Green
    #break
    #etc...
  #end
  #switch (B)
   #same here
  #end

  #sphere { ... texture { pigment { colour cx } } }
  #sphere { ... texture { pigment { colour cy } } }

  #declare iterator = iterator + increment
#end // #while ()

Happy ray-tracing,

B-o-b.
--

bob### [at] casimirrezelenstfr -- Linux, POV-Ray, LaTeX


Post a reply to this message

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