Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Fractalize Your Project

Author
Message
The Wendigo
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: A hole near the base of a tree in the US
Posted: 17th Nov 2004 09:18
Fractals are one of the most mystical and beautiful mathamtical masterpieces ever learned. Not only are they beautiful to look at, but they also can become very useful tools for your project. Ever want to create a random, yet realalistic landscape, a logical pattern of trees in a forrest, or even an entire galaxy of intricately placed stars? Fractals are a great way of accomplishing this.

The code included in the code box is code for the Mandelbrot set. You could modify this code for any fractal you wish, provided you know the forumulas and can convert them. I tried very hard to comment the code really well to show exactly what is happening and why. I hope you find this code very useful, and though this example is not really a practical application of fractals, it can be modified easily for such tasks. Enjoy!


Home of DOOP, Strata Works, and Height
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 17th Nov 2004 20:54
Nice!

Now to speed things up considerably,

change 'dot' command to:

ink GetColor(MandelbrotPixel(px, py, FRACT_ITERATIONS)),0
box x, y, x+1,y+1

dot is SO slow. BOX is much much faster.

Also put this at top:

sync on : sync rate 0


Look on my website for my old fractal generator. Allows you to zoom in with mouse!

Original was posted in 20 line challenge:

http://forum.thegamecreators.com/?m=forum_view&t=1886&b=11

Boo!
The Wendigo
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: A hole near the base of a tree in the US
Posted: 18th Nov 2004 04:46
That's cool. Yeah, I didn't throw any optimizations in because I mainly wanted to show how it was done. I, personally, would have locked the backbuffer and drawn directly to it. I also originally made one in VB6 a few days ago that allows you to zoom and scroll with the mouse. Fractals are so much fun!


Home of DOOP, Strata Works, and Height
MikeS
Retired Moderator
21
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: United States
Posted: 19th Nov 2004 05:21
Awesome snippet Wendigo.



A book? I hate book. Book is stupid.
(Formerly known as Yellow)
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 19th Nov 2004 11:53
Nice one Wendigo - I love fractals. Here's one I did a few months back. (It has a point and click zoom.)




The Wendigo
22
Years of Service
User Offline
Joined: 13th Sep 2002
Location: A hole near the base of a tree in the US
Posted: 21st Nov 2004 15:03 Edited at: 21st Nov 2004 15:18
Call me slow, it took me a little bit to realize yours is the mandelbrot set rotate 90 degrees, lol. Very nicely done. I wish I was that good with colors!

I just finished writing a basic Complex numbers class in VB6 so I can experiment more with fractals. It supports Adding, subtracting, multiplying and grabbing the norm or magnitude of the value. Off I go to play some more

[edit] arg. too slow. forget it. Guess ill be doing it by hand.


Home of DOOP, Strata Works, and Height
BiggAdd
Retired Moderator
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 22nd Nov 2004 04:52
I wish i could code full stop....... i'm gobsmacked....... thats is ace! well done too all of you!

Login to post a reply

Server time is: 2024-11-23 17:19:48
Your offset time is: 2024-11-23 17:19:48