Canopy

Look up at the trees

Log in to post a comment.

Canvas.setpenopacity(-1.0);
const t = new Turtle();

function drawBranch(x, y, length, angle, thickness) {
    const endX = x + Math.cos(angle) * length;
    const endY = y + Math.sin(angle) * length;
    
    t.jump(x, y);
    t.goto(endX, endY);
    
    // Draw smaller branches at the end
    if (length > 5) {
        const numBranches = Math.floor(3 + Math.random() * 3);
        for (let i = 0; i < numBranches; i++) {
            const newAngle = angle + (-0.5 + Math.random()) * Math.PI * 0.5;
            const newLength = length * (0.4 + Math.random() * 0.3);
            drawBranch(endX, endY, newLength, newAngle, thickness * 0.7);
        }
    }
}

function drawCanopyTree(centerX, centerY, size) {
    const numMainBranches = 5 + Math.floor(Math.random() * 4);
    const baseLength = size * (0.7 + Math.random() * 0.3);
    
    for (let i = 0; i < numMainBranches; i++) {
        const angle = (i / numMainBranches) * Math.PI * 2 + Math.random() * 0.5;
        drawBranch(centerX, centerY, baseLength, angle, 1);
    }
}

// Create a forest canopy view
const numTrees = 15;
const maxRadius = 200;

for (let i = 0; i < numTrees; i++) {
    const distance = Math.sqrt(Math.random()) * maxRadius;
    const angle = Math.random() * Math.PI * 2;
    
    const x = Math.cos(angle) * distance;
    const y = Math.sin(angle) * distance;
    
    // Trees get smaller as they get further from center (perspective)
    const size = 80 * (1 - distance/maxRadius) + 20;
    
    drawCanopyTree(x, y, size);
}

// Add some smaller connecting branches for magical effect
for (let i = 0; i < 100; i++) {
    const x = -maxRadius + Math.random() * maxRadius * 2;
    const y = -maxRadius + Math.random() * maxRadius * 2;
    const length = 10 + Math.random() * 20;
    const angle = Math.random() * Math.PI * 2;
    
    drawBranch(x, y, length, angle, 0.5);
}