|
|
Trying to render something in a sequence of colors using an animation. Lets just say
they are web buttons. I provide
this color cube source to illustrate that I am getting a lot of missing colors. What
I really need is a function that
converts a float (0..1) into an rgb value such that from 0 to 1 all colors are
represented (with enough granularity).
what I have so far is this, but the math is goofy somehow.
#declare KK=100; //number of steps total
#declare K=0; //represents the clock value
#declare cr=pow(KK+1,1/3); //cube root
#declare cr2=cr*cr; //cube root squared
#fopen myData "data.csv" write
#write( myData, "Number of frames\t",KK,"\n")
#write( myData, "cube root\t",cr,"\n")
#write( myData, "\nClock\tColor\n")
//simulate clock from 0 to 1
#while(K<=1)
#declare R=K;
#declare G=(K*cr)-int(K*cr);
#declare B=(K*cr2)-int(K*cr2);
//quantize the colors to the cube root
#declare R=(int(R*cr)) /cr;
#declare G=(int(G*cr)) /cr;
#declare B=(int(B*cr)) /cr;
#declare C=<R,G,B>;
#write(myData,K,"\t",C,"\n")
sphere{(C-0.5)*10,.5
texture{pigment{color C} finish{ambient 1} }
}
#declare K=K+0.01;
#end
#fclose myData
camera {
location <-10,2,-20>
look_at <0.0, 0.0, 0.0>
right x*image_width/image_height
}
background{ .5 }
=================
this gives the following values (my comments added)
Number of frames 100
cube root 4.65701
Clock Color
0 <0,0,0> <-good
0.01 <0,0,0.21473>
0.02 <0,0,0.42946>
0.03 <0,0,0.64419>
0.04 <0,0,0.85892> <-never gets to 1
0.05 <0,0.21473,0> <-green increments as blue resets.. this is right
0.06 <0,0.21473,0.21473>
0.07 <0,0.21473,0.42946>
0.08 <0,0.21473,0.64419>
0.09 <0,0.21473,0.85892>
0.1 <0,0.42946,0> <- again
0.11 <0,0.42946,0.21473>
0.12 <0,0.42946,0.42946>
0.13 <0,0.42946,0.64419>
0.14 <0,0.64419,0> <- wait! where is .85?
0.15 <0,0.64419,0.21473>
0.16 <0,0.64419,0.42946>
0.17 <0,0.64419,0.64419>
0.18 <0,0.64419,0.85892>
0.19 <0,0.85892,0>
0.2 <0,0.85892,0.21473>
0.21 <0,0.85892,0.42946>
0.22 <0.21473,0,0.64419> <-whoa! blue isnt resetting but green and blue do
anyway
0.23 <0.21473,0,0.85892>
0.24 <0.21473,0,0>
0.25 <0.21473,0,0.21473>
0.26 <0.21473,0,0.42946>
0.27 <0.21473,0.21473,0.64419>
0.28 <0.21473,0.21473,0>
0.29 <0.21473,0.21473,0.21473>
0.3 <0.21473,0.21473,0.42946>
0.31 <0.21473,0.42946,0.64419>
0.32 <0.21473,0.42946,0.85892>
0.33 <0.21473,0.42946,0>
0.34 <0.21473,0.42946,0.21473>
0.35 <0.21473,0.42946,0.42946>
0.36 <0.21473,0.64419,0.64419>
0.37 <0.21473,0.64419,0>
0.38 <0.21473,0.64419,0.21473>
0.39 <0.21473,0.64419,0.42946>
0.4 <0.21473,0.85892,0.64419>
0.41 <0.21473,0.85892,0.85892>
0.42 <0.21473,0.85892,0>
0.43 <0.42946,0,0.21473>
0.44 <0.42946,0,0.42946>
0.45 <0.42946,0,0.64419>
0.46 <0.42946,0,0.85892>
0.47 <0.42946,0,0>
0.48 <0.42946,0.21473,0.21473>
0.49 <0.42946,0.21473,0.42946>
0.5 <0.42946,0.21473,0.64419>
0.51 <0.42946,0.21473,0>
0.52 <0.42946,0.21473,0.21473>
0.53 <0.42946,0.42946,0.42946>
0.54 <0.42946,0.42946,0.64419>
0.55 <0.42946,0.42946,0.85892>
0.56 <0.42946,0.42946,0>
0.57 <0.42946,0.64419,0.21473>
0.58 <0.42946,0.64419,0.42946>
0.59 <0.42946,0.64419,0.64419>
0.6 <0.42946,0.64419,0>
0.61 <0.42946,0.64419,0.21473>
0.62 <0.42946,0.85892,0.42946>
0.63 <0.42946,0.85892,0.64419>
0.64 <0.42946,0.85892,0.85892>
0.65 <0.64419,0,0>
0.66 <0.64419,0,0.21473>
0.67 <0.64419,0,0.42946>
0.68 <0.64419,0,0.64419>
0.69 <0.64419,0,0.85892>
0.7 <0.64419,0.21473,0>
0.71 <0.64419,0.21473,0.21473>
0.72 <0.64419,0.21473,0.42946>
0.73 <0.64419,0.21473,0.64419>
0.74 <0.64419,0.42946,0>
0.75 <0.64419,0.42946,0.21473>
0.76 <0.64419,0.42946,0.42946>
0.77 <0.64419,0.42946,0.64419>
0.78 <0.64419,0.42946,0.85892>
0.79 <0.64419,0.64419,0>
0.8 <0.64419,0.64419,0.21473>
0.81 <0.64419,0.64419,0.42946>
0.82 <0.64419,0.64419,0.64419>
0.83 <0.64419,0.85892,0>
0.84 <0.64419,0.85892,0.21473>
0.85 <0.64419,0.85892,0.42946>
0.86 <0.85892,0,0.64419>
0.87 <0.85892,0,0.85892>
0.88 <0.85892,0,0>
0.89 <0.85892,0,0.21473>
0.9 <0.85892,0,0.42946>
0.91 <0.85892,0.21473,0.64419>
0.92 <0.85892,0.21473,0.85892>
0.93 <0.85892,0.21473,0>
0.94 <0.85892,0.21473,0.21473>
0.95 <0.85892,0.21473,0.42946>
0.96 <0.85892,0.42946,0.64419>
0.97 <0.85892,0.42946,0>
0.98 <0.85892,0.42946,0.21473>
0.99 <0.85892,0.42946,0.42946>
1 <0.85892,0.64419,0.64419> <- this should be somewhere near <1,1,1>
Post a reply to this message
|
|