Page 1 of 1

Custom functions?

Posted: Thu Dec 18, 2008 10:35 am
by Zirgion
What I'd like is custom functions that return a number (I don't see how that would be context sensitive).

This thought came out of frustration when working on a cfdg where I need to randomly rotate and set HSB values, even with the sort of "binary search" this means a lot of rules, when I could say for instance CIRCLE { b rand01() r rand0360() sat rand01() ... } and implement both only once.

I haven't really looked through the sources of this project (if you don't count the times when I've had to made changes in order to get it to compile), but I was wondering if it could be implemented as a special rule (with recursion possibilities).

Posted: Fri Dec 19, 2008 12:59 am
by MtnViewJohn
The current implementation doesn't allow for randomness. All of the geometry and color changes get compiled down to constants and there is no easy way for rules to have random elements that are different each time the rule is executed. I mean, you could do it but it would be a poor fit. You would probably have to place restrictions on what random changes are allowed in the same shape invocation.

We are working on a new version that compiles rules to byte codes instead of constants. The ability to do truly random changes falls out pretty easily with this style of implementation. Named parameters is also being considered.