Hello all,
This follows up on my previous post still associated with a fractal project Im currently working on.
I am aware that the following question may involve arraylists of which Im not yet familiar with, Im hoping to get there pretty soon but I would appreciate some guidance on how to make the recursion objects appear one after the other…
Thanks!
PShape s; // The PShape object - Cube
int a = 500; // Declare variable - Radious Cube
float b = a * sqrt(3) / 2; // Height of triangle
float c = a * 2 / 3; // Circle02 Radious - 7Days of Creation
float f = c * cos(radians(30));
float g = c * cos(radians(60));
void setup() {
size(1920, 1280);
background(255);
stroke(0);
strokeWeight(1);
frameRate(50);
s = createShape(); //Cube Outline
s.beginShape();
s.noFill();
s.stroke(0);
s.vertex(width/2, height/2-a);
s.vertex(width/2+b, height/2-a/2);
s.vertex(width/2+b, height/2+a/2);
s.vertex(width/2, height/2+a);
s.vertex(width/2-b, height/2+a/2);
s.vertex(width/2-b, height/2-a/2);
s.endShape(CLOSE);
}
void draw() {
// ----------------Draw Cube--------------
shape(s); //Cube Outline
//------------------Centre Base Circles --------------
drawCircle(width/2,height/2, c);
drawCircle(width/2,height/2-c, c);
drawCircle(width/2,height/2+c, c);
drawCircle(width/2+f,height/2-g, c);
drawCircle(width/2+f,height/2+g, c);
drawCircle(width/2-f,height/2-g, c);
drawCircle(width/2-f,height/2+g, c);
}
void drawCircle(float x, float y, float radius) {
stroke(0);
noFill();
ellipse(x, y, radius, radius);
if(radius > 20) {
drawCircle(x, y, radius/4);
drawCircle(x, y + radius/4, radius/4);
drawCircle(x, y - radius/4, radius/4);
drawCircle(x + radius/4 * cos(radians(30)), y - radius/4 * cos(radians(60)), radius/4);
drawCircle(x + radius/4 * cos(radians(30)), y + radius/4 * cos(radians(60)), radius/4);
drawCircle(x - radius/4 * cos(radians(30)), y - radius/4 * cos(radians(60)), radius/4);
drawCircle(x - radius/4 * cos(radians(30)), y + radius/4 * cos(radians(60)), radius/4);
drawCircle(x, y + radius/2, radius/4);
drawCircle(x, y - radius/2, radius/4);
drawCircle(x + radius/2 * cos(radians(30)), y - radius/2 * cos(radians(60)), radius/4);
drawCircle(x + radius/2 * cos(radians(30)), y + radius/2 * cos(radians(60)), radius/4);
drawCircle(x - radius/2 * cos(radians(30)), y - radius/2 * cos(radians(60)), radius/4);
drawCircle(x - radius/2 * cos(radians(30)), y + radius/2 * cos(radians(60)), radius/4);
}
}