Logo by KRAFTWERK - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Check out the originating "3d Mandelbulb" thread here
 
*
Welcome, Guest. Please login or register. April 23, 2024, 11:10:53 AM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1]   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: 2D IFS Viewer in Flash  (Read 6249 times)
0 Members and 1 Guest are viewing this topic.
Serisium
Forums Newbie
*
Posts: 1


« on: March 26, 2010, 03:39:31 AM »

I made this a while ago, and I thought I might post it.

<a href="http://www.truimagz.com/host/serisium/flash/IFS_engine.swf" target="_blank">http://www.truimagz.com/host/serisium/flash/IFS_engine.swf</a>

Here's the source code in AS3:

Code:
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.geom.Point;
var bmd:BitmapData=new BitmapData(800,800,false,0x6666ff);
var bm:Bitmap=new Bitmap(bmd);
bm.x=100;
bm.y=100;
this.addChild(bm);
var p:Point = new Point();
var fractals:Array = new Array(9);
fractals[0]={name:"Sierpinski Triangle",desc:"...",rules:new Array({a:.5,b:0,c:0,d:.5,e:0,f:0,p:1/3},{a:.5,b:0,c:0,d:.5,e:.25,f:.5,p:1/3},{a:.5,b:0,c:0,d:.5,e:.5,f:0,p:1/3})};
fractals[1]={name:"Sierpinski Carpet",desc:"...",rules:new Array({a:1/3,b:0,c:0,d:1/3,e:0,f:0,p:1/8},{a:1/3,b:0,c:0,d:1/3,e:1/3,f:0,p:1/8},{a:1/3,b:0,c:0,d:1/3,e:2/3,f:0,p:1/8},{a:1/3,b:0,c:0,d:1/3,e:0,f:1/3,p:1/8},{a:1/3,b:0,c:0,d:1/3,e:2/3,f:1/3,p:1/8},{a:1/3,b:0,c:0,d:1/3,e:0,f:2/3,p:1/8},{a:1/3,b:0,c:0,d:1/3,e:1/3,f:2/3,p:1/8},{a:1/3,b:0,c:0,d:1/3,e:2/3,f:2/3,p:1/8})};
fractals[2]={name:"Barnsley's fern",desc:"...",rules:new Array({a:0.00,b:0.00,c:0.00,d:0.16,e:0.00,f:0.00,p:.01},{a:0.85,b:0.04,c:-0.04,d:0.85,e:0.00,f:1.6,p:.85},{a:0.20,b:-0.26,c:0.23,d:0.22,e:0.00,f:1.6,p:.07},{a:-.15,b:0.28,c:0.26,d:0.24,e:0.00,f:0.44,p:.07})};
fractals[3]={name:"Cantor maze",desc:"...",rules:new Array({a:1/3,b:0,c:0,d:1/3,e:1/3,f:2/3,p:1/7},{a:0,b:1/3,c:1,d:0,e:2/3,f:0,p:3/7},{a:0,b:-1/3,c:1,d:0,e:1/3,f:0,p:3/7})};
fractals[4]={name:"5-sided crystal",desc:"...",rules:new Array({a:.382,b:0,c:0,d:.382,e:.3072,f:.6190,p:.2},{a:.382,b:0,c:0,d:.382,e:.6033,f:.4044,p:.2},{a:.382,b:0,c:0,d:.382,e:.0139,f:.4044,p:.2},{a:.382,b:0,c:0,d:.382,e:.1253,f:.0595,p:.2},{a:.382,b:0,c:0,d:.382,e:.4920,f:.0595,p:.2})};
fractals[5]={name:"Diagonal X",desc:"...",rules:new Array({a:1/3,b:0,c:0,d:1/3,e:0,f:0,p:1/5},{a:1/3,b:0,c:0,d:1/3,e:2/3,f:0,p:1/5},{a:1/3,b:0,c:0,d:1/3,e:0,f:2/3,p:1/5},{a:1/3,b:0,c:0,d:1/3,e:2/3,f:2/3,p:1/5},{a:1/3,b:0,c:0,d:1/3,e:1/3,f:1/3,p:1/5})};
fractals[6]={name:"Koch curve",desc:"...",rules:new Array({a:1/3,b:0,c:0,d:1/3,e:0,f:0,p:1/4},{a:1/6,b:-1/3.5,c:1/3.5,d:1/6,e:1/3,f:0,p:1/4},{a:1/6,b:1/3.5,c:-1/3.5,d:1/6,e:1/2,f:1/3.5,p:1/4},{a:1/3,b:0,c:0,d:1/3,e:2/3,f:0,p:1/4})};
fractals[7]={name:"Tree #1",desc:"...",rules:new Array({a:0,b:0,c:0,d:.5,e:0,f:0,p:.05},{a:.42,b:-.42,c:.42,d:.42,e:0,f:.2,p:.4},{a:.42,b:.42,c:-.42,d:.42,e:0,f:.2,p:.4},{a:.1,b:0,c:0,d:.1,e:0,f:.2,p:.15})};
fractals[8]={name:"Tree #2",desc:"...",rules:new Array({a:.195,b:-.488,c:.344,d:.443,e:.4431,f:.2452,p:.1699},{a:.462,b:.414,c:-.252,d:.361,e:.2511,f:.5692,p:.1811},{a:-.058,b:-.07,c:.453,d:-.111,e:.5976,f:.0969,p:.2161},{a:-.035,b:.07,c:-.469,d:-.022,e:.4884,f:.5069,p:.2198},{a:-.637,b:0,c:0,d:.501,e:.8562,f:.2513,p:.2131})};
var index:int=0;
btn_reset.addEventListener(MouseEvent.CLICK, reset);
btn_prev.addEventListener(MouseEvent.CLICK,prevfractal);
btn_next.addEventListener(MouseEvent.CLICK,nextfractal);
addEventListener(Event.ENTER_FRAME, ifs);
function prevfractal(event:MouseEvent):void {
index-=1;
if(index==-1)
index=8;
bmd.fillRect(bmd.rect,0x006666ff);
}
function nextfractal(event:MouseEvent):void {
index+=1;
if(index==9)
index=0;
bmd.fillRect(bmd.rect,0x006666ff);
}
function reset(event:Event):void {
bmd.fillRect(bmd.rect,0x6666ff);
}
function ifs(event:Event):void {
for (var j:Number = 0; j < 1000; j++) {
var rand:Number=Math.random();
for (var i:Number = 0; i < fractals[index].rules.length; i++) {
if (rand<fractals[index].rules[i].p) {
var rule:Object=fractals[index].rules[i];
break;
} else {
rand-=fractals[index].rules[i].p;
}
}
var newp:Point = new Point((rule.a*p.x)+(rule.b*p.y)+(rule.e),(rule.c*p.x)+(rule.d*p.y)+(rule.f));
bmd.setPixel(800*newp.x,800*(1-newp.y),0x443322);
p=newp;
}
}
« Last Edit: March 26, 2010, 03:44:35 AM by Serisium » Logged
Timeroot
Fractal Fertilizer
*****
Posts: 362


The pwnge.


WWW
« Reply #1 on: March 26, 2010, 05:27:36 AM »

Nice applet. I see it just uses the regular affine transforms; that tree #2, I must say, looks like of the most realistic fractal trees I've ever seen! Very nice little thing!  Repeating Zooming Self-Silimilar Thumb Up, by Craig
Logged

Someday, man will understand primary theory; how every aspect of our universe has come about. Then we will describe all of physics, build a complete understanding of genetic engineering, catalog all planets, and find intelligent life. And then we'll just puzzle over fractals for eternity.
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
FOV issue with navigator and going between nav and main viewer bug reporting gregsage 4 2373 Last post May 09, 2012, 05:39:58 PM
by lenord
Cutting planes defined relative to the viewer / camera? feature request cytotox 4 2720 Last post June 07, 2013, 09:44:20 PM
by Jesse
Dodgeball with Flash Gordon Mandelbulb3D Gallery Sitting Duck 0 1560 Last post June 29, 2013, 11:34:23 AM
by Sitting Duck
Interactive Online Mandelbrot Set Viewer General Discussion edsuom 0 4477 Last post May 31, 2015, 09:52:31 PM
by edsuom
Fractal trees (displayed in the STL viewer) 3D Fractal Generation Max Sinister 0 2577 Last post May 03, 2016, 11:11:29 PM
by Max Sinister

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.167 seconds with 27 queries. (Pretty URLs adds 0.012s, 2q)