Hello! Today I'll give you a brief breakdown on how Math can be used to some fairly generate nifty images.
For starters, it helps to know that all pictures on a computer are formed from tiny colored squares called pixels (which stands for picture element). Each pixel is square in a large rectangular grid. Using this knowledge know, you can map every location on the screen to a pixel on the grid at (x, y).
And next, is the general idea behind fractals, which are these funky shapes split between dimensions. They branch and split repeatedly into smaller pieces at the edges, in what is known as recursive behaviour. Because of their odd branching characteristics, these can be used to mimic complex shapes that occur in real life: such as trees, plant life, mountains, lightning, snowflakes.
Sadly, I'm not quite that artistic when it comes to fractals, so I present to you, the very famous Mandelbrot set.
Nifty looking, right? The Mandelbrot set, was a discovered by a French mathematician, Benoit B. Mandelbrot, in the year 1975. As far as math goes, fractals are a fairly new thing.
Let's zoom in a bit...
Here's an even deeper zoom...
Now for the super close-up:
...As you can see, some pretty psychedelic images can be formed from fractals, too. Now let's jump into the details about how the image was constructed!
Firstly, the pictures use the HSV (Hue-Saturation-Value) Color Model to create those nifty thermal effects.
Let me explain:
These fractals were generated by using a simple coloring scheme using the above concept. The closer to the Mandelbrot Set, the greater the Hue (and it cycles when it goes over 360). Any part INSIDE the Mandelbrot Set is colored blue.
The actual steps taken to generate the picture are a little more... elaborate. Yet, they are here for interest and completeness.
Phew! That was a mouthful.
With a bit of clever work, you can translate these steps to a computer programming language that has a graphics package. It's a fairly fun exercise to try.
One thing to note though: Drawing fractals can be slow. You need to be patient with your computer if you want to try this, especially if it's not a top-notch one.
So there you go, I've shown you how you can make funky art with a bit of math and a computer.
...So, isn't math exciting? Come on, admit it, part of you thinks that was pretty cool!
Well, just one more thing. I wanted to paste my code here, the reasons being that...
** You can download this program to play with: http://www.bananattack.com/stuff/FractalMaker.zip
If you're not into code, you can skip over this.So here's the source code written in Lua, with free game engine called Verge. It essentially does the same as the description above, but it's a runnable script,
function autoexec() canvas = v3.NewImage(v3.ImageWidth(v3.screen), v3.ImageHeight(v3.screen)) v3.RectFill(0, 0, v3.ImageWidth(canvas), v3.ImageHeight(canvas), 0, canvas) v3.SetLucent(60) Mandelbrot(canvas, 100) v3.CopyImageToClipboard(canvas) while true do v3.Blit(0, 0, canvas, v3.screen) v3.ShowPage() end end function Mandelbrot(dest, max_iterations) local width = v3.ImageWidth(dest) local height = v3.ImageWidth(dest) local color = 0 local iteration = 0 local startX, startY local x, y, xtemp for i = 0, width - 1, 2 do for j = 0, height - 1, 2 do color = 0 -- Uncomment these other ones to see them in action! --[[ Standard Mandelbrot pic startX = -2 + (i / width * 4) startY = -2 + (j / height * 4)]] --[[ Intesting thing #1 startX = -1.5 + (i / width * 1) startY = -0.5 + (j / height * 2)]] --[[ Intesting thing #2 startX = -0.05 + (i / width * 1) startY = -0.015 + (j / height * 1)]] --[[ Intesting thing #3]] startX = -0.73 + (i / width * 0.01) startY = -0.25 + (j / height * 0.01) x = startX y = startY iteration = 0 while x^2 + y^2 <= 4 and iteration < max_iterations do xtemp = x^2 - y^2 + startX y = 2 * x * y + startY x = xtemp iteration = iteration + 1 end color = v3.HSV(iteration * 6, 255, 255) color2 = v3.HSV(iteration * 6, 255, 255) Plot(i, j, color, color2, dest) end end end function Plot(x, y, color, color2, dest) v3.CircleFill(x, y, v3.Random(2, 8), v3.Random(2, 8), v3.MixColor(color, color2, v3.Random(0, 255)), dest) end
Math is full of intriguing things...