POV-Ray : Newsgroups : povray.general : a really dumb mistake : Re: a really dumb mistake Server Time
23 Apr 2024 19:48:27 EDT (-0400)
  Re: a really dumb mistake  
From: Bald Eagle
Date: 11 Sep 2017 13:50:05
Message: <web.59b6cc01d9dfcaaec437ac910@news.povray.org>
> I might try to code it up tonight, unless someone beats me to it   ;)

or over lunch  :D

Like so:

#macro CycleValues (_Array, _Counter)
 // Round-robin cycle through N values
 // Bill Walker September 2017
 #local N = dimension_size (_Array, 1);
 #local selector = mod (_Counter, N);
 // selector will range from 0 to N-1
 // Return the value in _Array corresponding to _Counter
 _Array [selector]
#end // end macro CycleValues


#declare RoundRobin = array [4] {2, 5, 9, 13};
#for (i, 0, 10)
 #declare Value = CycleValues (RoundRobin, i);
 #debug concat ("Array value for i=", str(i, 2, 0), " is ", str(Value, 3, 0),
"\n")
#end // end for i


Post a reply to this message

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