POV-Ray : Newsgroups : povray.advanced-users : how do i get on the up and up with color? : Re: how do i get on the up and up with color? Server Time
30 Jul 2024 12:28:33 EDT (-0400)
  Re: how do i get on the up and up with color?  
From: Margus Ramst
Date: 10 Aug 1999 20:06:57
Message: <37B0BEA2.8CA57F86@peak.edu.ee>
I suggest you use this interpolation macro, it's very flexible:

//Interpolation
//GC - global current
//GS - global start
//GE - global end
//TS - target start
//TE - target end
//EXP - interpolation exponent (linear, cubic etc.)

#macro Interpolate(GC,GS,GE,TS,TE,EXP)
        (TS+(TE-TS)*pow((GC-GS)/(GE-GS),EXP))
#end

Do something like this:

#declare StartColor=<1,1,0>;
#declare EndColor=<0,1,0>;
#declare N=10;
#declare C=0;

#while(C<10)
    sphere{y*C, 0.5
           pigment{rgb Interpolate(C,0,N,StartColor,EndColor,1)}
          }
    #declare C=C+1;
#end

Here, pigment changes from StartColor to EndColor as C changes from 0 to N. The
final parameter is 1, meaning linear interpolation.
I use this macro extensively, even though this particular example could be
achieved more efficiently.

Margus

Noah A wrote:
> 
> i'm using a while statment to make a bunch of "things" as they rise on
> the y access i'd like them to incease certain colors. how would i use an
> array to do this?


Post a reply to this message

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