|
|
clipka <ano### [at] anonymousorg> wrote:
> Challenge accepted ;)
>
> #declare MY_VALUE = 10;
> #for(C,1,19)
> #debug concat("\n","My Value = ",str(MY_VALUE,1,0),"\n")
> #declare MY_VALUE = 43-MY_VALUE;
> #end
So, I looked further into this, since it was so elegant,
and I came across this discussion, and further suggested improvement:
from:
https://stackoverflow.com/questions/18941019/simplest-way-to-toggle-a-integer-variable-between-two-values
( ^= operator is the XOR operator)
"Another way is to toggle an index between 0 and 1 and index an array with that:
int main() {
int const values[] = {0x55, 0xaa};
int selector = 0;
selector ^= 1; // toggle index
int value = values[selector]; // select value
}
This is also future-resistant. If in the future OP wants to round-robin between
3, 4, or N values, just add to the array and change selector ^= 1 to selector =
(selector+1)%N."
------
I'm unfamiliar with the bitwise operators in POV-Ray, so interpreting the docs
is a bit unclear to me.
"bitwise_xor(A,B,...)
Bitwise XOR of two or more float values considered as integers."
This would make a sweet little macro for people to use in lots of future scene
files - so good, it should be in one of the standard include files.
I might try to code it up tonight, unless someone beats me to it ;)
Post a reply to this message
|
|