Custom functions?

Let the developers know what you think of the software and what can be done to either improve the CFDG language or the Context Free program.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
Zirgion
Posts: 5
Joined: Wed Mar 05, 2008 10:17 am

Custom functions?

Post 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).

User avatar
MtnViewJohn
Site Admin
Posts: 882
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Post 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.

Post Reply