|
|
The bare formula would be to simply multiply the vector by 255 (not 256, because
0 to 255 makes 256 entries, total.)
(A full 5-component vector as an example...)
#declare BB = <.327,.586,.902,.431,.202>;
#declare BB_LARGE = BB*255;
// To test this...
#debug concat("\n","BB_LARGE = <",vstr(5,BB_LARGE,", ",0,3),">","\n")
another example...
#declare CC = <0,1,.5>;
#declare CC_LARGE = CC*255;
// to test this...
#debug concat("\n","CC_LARGE = <",vstr(3,CC_LARGE,", ",0,3),">","\n")
To pick out just one of the values, you would use dot notation--
.red, .green, .blue, .filter, .transmit--
#declare BB_LARGE_FILTER = (BB_LARGE.filter);
// To test this...
#debug concat("\n","BB_LARGE_FILTER = ",str(BB_LARGE_FILTER,0,3),"\n")
If you want to eliminate the fractional parts to get just the integers, you
could use POV-Ray's built-in functions like int, floor, or ceil. Like...
int(BB_LARGE.filter)
But the integer results-- using either of the three function choices-- may be
'one integer higher or lower' than what you want. You may have to decide in
which 'direction' to go.. For example: if BB*255 turns out to be
<.999,0,254.999,0,128.000>
then int(BB_LARGE.red) would be 0.000-- because int 'rounds toward zero'; and
int(BB_LARGE.blue) would be 254, not 255. That's the same result you would get
when using floor. Using ceil(...) instead would have a similar but opposite
effect-- ceil(BB_LARGE.red) would be 1.000, while ceil(BB_LARGE.blue) would be
255. BUT, if BB_LARGE.red happended to be .001, ceil would still make it 1.000.
Just a small detail to be aware of.
Post a reply to this message
|
|