Okay, so today I wanted to mess around with something I’ve been calling a “tree crystal ball.” It’s basically a fun little project where I try to make a digital crystal ball that, instead of showing the future, displays a cool-looking tree structure. I have no idea if this will even work, but let’s find out!

Getting Started
First things first, I needed something to draw on. I figured a simple HTML canvas would do the trick. I created a basic HTML file and tossed in a canvas element. Nothing fancy, just enough to get a drawing surface.
Next, I needed some JavaScript to actually draw the tree. I remember those fractal tree examples from way back, so I thought I’d start with that. I grabbed some basic code for drawing a fractal tree and pasted it into my script.
Making it Look “Crystal Ball-ish”
Now came the tricky part – making it look like it’s inside a crystal ball. My first thought was to draw a big circle around the tree. Easy enough. I just used the canvas’s `arc` function to draw a circle that encompassed the whole tree.

But a plain circle looked boring. I needed some kind of “glass” effect. I messed around with gradients for a bit, trying to make it look like light was reflecting off the surface. I added a radial gradient to the circle, starting with a lighter color in the center and fading to a darker color at the edges.
It still looked kind of flat, though. So, I thought, “What about a highlight?” I added another, smaller, white circle near the top-left of the main circle, to simulate a light reflection. It’s super rough, but it added a little something.
Tweaking the Tree
The tree itself was pretty basic, just a brown trunk and branches. I wanted it to look more mystical. I thought, why not make the branches glow? I added a bit of code that changed the color of the branches at each recursion, cycling through some different colors.

I also played around with the branching angles and lengths. By making the branches split at slightly random angles and making each branch a bit shorter than the previous one, I got a more organic-looking tree. It’s not perfect, but it’s way better than the stiff, symmetrical tree I started with.
Putting it all Together
Finally, I hooked everything up so that the tree would redraw itself every so often. This made it look like the tree was constantly growing and shifting inside the crystal ball. It’s a very simple animation, but it gives this effect of constant change, which is pretty nice!
Here’s a quick rundown of the key things I did:
- Drew a circle: Used `arc` to create the basic crystal ball shape.
- Added a gradient: Made the circle look more 3D with a radial gradient.
- Drew a highlight: Added a small white circle for a reflection effect.
- Drew a fractal tree: Started with basic fractal tree code.
- Added Color and made some Random Branches: Make it glowing with many colors, and the shape looks natural.
- Animated it: Redrew the tree periodically to make it look alive.
It’s definitely not a real crystal ball, but it’s a fun little visual effect. I might try adding some more details later, like maybe some particles floating around inside the ball, or maybe even trying to make the tree react to mouse movements. This was a fun little experiment, and I’m pretty happy with how it turned out, even if it is super basic!