Hi! I’m playing around with the code for Casey Reas’ Repeat: Recursion Tree ( http://formandcode.com/code-examples/repeat-recursive-tree ).
I’d like to change it so that instead of there being a 2% chance of it creating branches, it checks the position in an array and bases the decision on that. So with every level of the recursion, I want it to move to the next position in the array.
This is how I’ve tried to do it:
void draw() {
background(255);
translate(width/2, height/2);
seed1(dotSize, radians(270), 0, 0, 0);
seed1(dotSize, radians(90), 0, 0, 0);
}
void seed1(float dotSize, float angle, float x, float y, int i) {
if (dotSize > 1.0) {
if (ffs[i]==true) {
ellipse(x, y, dotSize, dotSize);
float newx = x + cos(angle) * dotSize;
float newy = y + sin(angle) * dotSize;
int newi = i + 1;
seed1(dotSize * 0.99, angle - angleOffsetA, newx, newy, newi);
}
In practice, ‘i’ moves forward one position in the array, from 0 to 1, and then stays on 1 for every level of recursion onward.
Can anyone help me with how to get better results?