I asked several different AI engines to create an animated Sierpinski triangle and below are the results. Click on the black images below to start a given animation. Only one can be running at a time - the one currently active has a green border.

I purposely gave the engines a short and vague prompt (I literally only typed "animated Sierpinski triangle in JavaScript") to see what they come up with.
All of them use a Canvas and a requestAnimationFrame loop, except Claude, which addtionally has a setInterval for the sparkles, and Vondy, which uses "delay". But as you can see, each approach has its own uniqueness. Several other engines that I tried failed (the program did not draw the triangle at all) and I'm not showing those on this page.
All I did is copy-pasted the code from AI into this page and resized all the canvases to 400x350 pixels. The only exception was Claude - it gave me control buttons, but they didn't jive well with the other programs, so I had to remove them. The animations below are being calculated real-time, those are not videos. In case you want to try playing with AI code generation yourself: I only used engines that are free or at least offer a free trial.

The Sierpinski triangle is a mathematical concept: self-similar fractal. It is constructed by starting with an equilateral triangle and recursively removing smaller equilateral triangles from its remaining area.

In simple terms: start with a triangle. Divide it into three smaller triangles. Then divide each of the smaller triangles into three even smaller triangles. And so on, to infinity. Of course our programs can only handle a couple of levels of iterations due to time and screen resolution limitation.

Enjoy the show!

Chat GPT



Claude

definitely came with the most bells and whistles: control buttons (which worked well, but I had to remove them for technical reasons), plus glow and sparkle, which have nothing to do with the algorithm, but look fancy.



Depth: 0
Triangles: 1


Google

Similar to ChatGPT, but the triangles are not filled.



NinjaTech

The only engine that decided to draw the triangle dot by dot. Also, while the previous programs were drawing one level of recurssion at a time, this one doesn't set a maximum level. So theoretically it would draw a mathematically perfect shape if it didn't restart after plotting 10,000 points.



Vondy

Unique approach - one small triangle at a preset level of recurssion.



Check out these programming tutorials:

JavaScript:

Minesweeper game (100 lines)

Optical illusion (18 lines)

Oldschool fire effect (20 lines)

8-bit style sine text scroller (30 lines)

Animated fractal (32 lines)

Physics engine for beginners

Starfield (21 lines)

Yin Yang with a twist (4 circles and 20 lines)

Interactive animated sprites

Your first program in JavaScript: you need 5 minutes and a notepad


Fractals in Excel