I'll create an HTML file with JavaScript and CSS to visualize tree root growth for different tree types. This will be an interactive, visually appealing visualization.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Tree Root Growth Visualizer</title>
<style>
body {
font-family: 'Arial', sans-serif;
background-color: #f0f4f0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
padding: 20px;
box-sizing: border-box;
}
.container {
background-color: white;
border-radius: 15px;
box-shadow: 0 10px 25px rgba(0,0,0,0.1);
padding: 30px;
text-align: center;
max-width: 800px;
width: 100%;
}
#rootCanvas {
border: 2px solid #2c3e50;
background-color: #e8f4ea;
border-radius: 10px;
}
select {
margin: 15px;
padding: 10px;
font-size: 16px;
border-radius: 5px;
border: 1px solid #3498db;
}
</style>
</head>
<body>
<div class="container">
<h1>🌳 Tree Root Growth Visualizer</h1>
<select id="treeSelector">
<option value="willow">Willow</option>
<option value="redwood">Redwood</option>
<option value="acacia">Acacia</option>
</select>
<canvas id="rootCanvas" width="600" height="400"></canvas>
</div>
<script>
const canvas = document.getElementById('rootCanvas');
const ctx = canvas.getContext('2d');
const treeSelector = document.getElementById('treeSelector');
const rootGrowthPatterns = {
willow: {
color: '#8B4513',
spreadFactor: 1.2,
depth: 0.7,
branchProbability: 0.6
},
redwood: {
color: '#5D4037',
spreadFactor: 0.8,
depth: 1.0,
branchProbability: 0.4
},
acacia: {
color: '#6D4C41',
spreadFactor: 1.5,
depth: 0.5,
branchProbability: 0.7
}
};
function drawRoot(x, y, length, angle, depth, treeType) {
if (depth <= 0) return;
const pattern = rootGrowthPatterns[treeType];
ctx.beginPath();
ctx.strokeStyle = pattern.color;
ctx.lineWidth = depth * 3;
ctx.save();
ctx.translate(x, y);
ctx.rotate(angle);
ctx.moveTo(0, 0);
ctx.lineTo(0, -length);
ctx.stroke();
if (Math.random() < pattern.branchProbability) {
drawRoot(0, -length, length * pattern.spreadFactor,
Math.PI / 4, depth - 0.2, treeType);
drawRoot(0, -length, length * pattern.spreadFactor,
-Math.PI / 4, depth - 0.2, treeType);
}
ctx.restore();
}
function visualizeRoots() {
const treeType = treeSelector.value;
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.save();
ctx.translate(canvas.width/2, canvas.height);
drawRoot(0, 0, 100, 0, 5, treeType);
ctx.restore();
}
treeSelector.addEventListener('change', visualizeRoots);
visualizeRoots();
</script>
</body>
</html>
This visualization offers several key features:
- Interactive Tree Selection
- Dropdown to choose between Willow, Redwood, and Acacia
- Each tree type has unique root growth characteristics
- Visual Root Growth Simulation
- Recursive root drawing algorithm
- Randomized branching
- Depth-based line thickness
- Tree-specific color and spread
- Design Elements
- Responsive layout
- Soft, earthy color palette
- Subtle shadows and rounded corners
- Canvas-based rendering
- Root Growth Parameters
- Spread Factor: How wide roots grow
- Depth: Maximum recursion depth
- Branch Probability: Likelihood of root branching
When you open this HTML file, you'll see an interactive visualization where changing the tree type dynamically updates the root growth pattern. The roots will look different for each tree type, reflecting their natural growth characteristics.
Would you like me to explain any part of the code or discuss the root growth visualization in more detail?