Drawing dragon curve fractals

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
clofresh
Citizen
Posts: 87
Joined: Sun Jul 26, 2009 4:21 pm
Contact:

Drawing dragon curve fractals

Post by clofresh »

Hey guys,

I've been trying to figure out an interesting way to model the growth of a fungus-like corruption for this game I'm making and I ended up implementing dragon curves:
dragoncurves.gif
dragoncurves.gif (216.22 KiB) Viewed 2732 times
Code is here: https://gist.github.com/clofresh/5691856

I'm not sure if I'll end up using it because it looks too regular and I'd like to the growth to look more organic. Do you guys have any suggestions for a cool growth algorithm?
----------------------------------------
Sluicer Games
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Drawing dragon curve fractals

Post by micha »

Maybe you can get more irregular shapes if you add random perturbations. If I get it correctly, then the algorithm for the dragon curve replaces each line segment by a more complex shape (two line segments) each iteration. You could either perturb the points coordinates randomly or you could make up more than one substitution rule and then in each iteration for each line segment select on rule randomly.
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Drawing dragon curve fractals

Post by vrld »

Very cool demo. Maybe you can get a more 'organic' effect using cellular automata and a pinch of math.random(). Here is something I hacked together last night:
grow1.jpg
grow1.jpg (8.43 KiB) Viewed 2677 times
grow2.jpg
grow2.jpg (44.33 KiB) Viewed 2677 times
Attachments
grow.love
(980 Bytes) Downloaded 120 times
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
clofresh
Citizen
Posts: 87
Joined: Sun Jul 26, 2009 4:21 pm
Contact:

Re: Drawing dragon curve fractals

Post by clofresh »

That's really cool! Yeah I was also considering cellular automata but I didn't like the rules of Game of Life, though I guess I can just make up my own rules like you did.
----------------------------------------
Sluicer Games
User avatar
chezrom
Citizen
Posts: 59
Joined: Tue May 28, 2013 11:03 pm
Location: France

Re: Drawing dragon curve fractals

Post by chezrom »

You can also use an accretion simulation by random walk.
The time and memory usage can be big : I use about 250 walkers in my simulation, and 100 walk steps for each per seconds.
accretion1.jpg
(Sorry vrld, I reuse some of your code)

EDIT: I correct a stupid bug that make the accretion not symetrical
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 86 guests