The Bazon Fractal
The idea is simple. To draw the pixel (x, y) of the image, you compute some function of x and y, and select a color based on the returned value. Certain functions lead to impressive results. But you need to be either too lucky, or a passionate mathematician, to discover a function that outputs something meaningful.
Look for instance at the following (and check the source of the page to see how it's done):
That's pretty much how it looked 20 years back, on our ZX Spectrum where you didn't have the luxury of putting more than two colors in an 8x8 pixels square. So it was monochrome. Luckily for us, on today hardware we do have the option, so let's try it:
The above just uses an array of 32 shades of grey, from plain black to white. It still has some rough edges, so I figured out that it would be cool to do some kind of "antialiasing". How to do that? Well, we can use a 64 colors array, which has black at the extremes and white at the middle. Go figure:
You can generate interesting variations by slightly changing the function or a few coefficients. Try it below. For instance if you change the last minus to plus, you get the circles above.
| Predefined functions: |
In the code below you can use x, y, width, height and mod variables, and you need to return some value between 0 and mod. The abs function is a helper for negative values (it's not exactly the same as Math.abs).
Note that animation will probably suck unless your browser is Chrome. It's quite slow with Firefox, and I didn't test with anything else. With Chrome it works fine. The animation function simply increases the Mod value then redraws.