} void drawTriangle(float x,float y,float s,float r,int l,boolean split,int c) { float b = d / 2; float c = d / factor; float a = sqrt(sq(c) - sq(b)); translate(x, y); rotate(radians(r)); fill(c); triangle(0, 0, -b, a, b, a); level++; if(!split && l < maxLevel) drawTriangle(0, 0, s, 0, level, false, #003c82); else if(l < maxLevel) { drawTriangle(-(a / sqrt(3)), a, c, 150, level, false, #003c82); drawTriangle(a / sqrt(3), a, c, -150, level, false, #003c82); // ... drawTriangle(0, a - childA, childBottom, 0, level, true, #50c8fa); drawTriangle(0, a - childA, childBottom, 120, level, true, #50c8fa); drawTriangle(0, a - childA, childBottom, -120, level, true, #50c8fa); } }