In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

fern

Get Adobe Flash player
by 12346 18 Jan 2011
/**
 * Copyright 12346 ( http://wonderfl.net/user/12346 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/ueZ6
 */

//http://en.wikipedia.org/wiki/Barnsley%27s_fern
package{import flash.display.*;import flash.events.*
[SWF(frameRate=120)]public class fern extends Sprite{
 private var canvas:BitmapData,x1:Number=0,y1:Number=0
 public function fern(){
  addChild(new Bitmap(canvas=new BitmapData(465,465,!1,0)))
  addEventListener("enterFrame",function():void{calc(500)})
 }
 private function plot(X:Number,Y:Number):void{
  var x:int=(Y+X)*32,y:int=(Y-X+4)*32,_:uint=canvas.getPixel(x,y)
  canvas.setPixel(x,y,_<0xff00?_+0x100:_)
 }
 private function calc(k:int):void{
  var _:int=Math.random()*100,y2:Number=0
  while(_>=p[y2])y2++
  y2=c[_=y2]*x1+d[_]*y1+f[_]
  plot(x1=a[_]*x1+b[_]*y1+e[_],y1=y2)
  if(--k>0)calc(k)
 }
}}const//x->ax+by+e, y->cx+dy+f
a:Array=[0   , .85, .2 ,-.15],
b:Array=[0   , .04,-.26, .28],
c:Array=[0   ,-.04, .23, .26],
d:Array=[ .16, .85, .22, .24],
e:Array=[0   ,0   ,0   ,0   ],
f:Array=[0   ,1.6 ,1.6 , .44],
p:Array=[   1,  86,  93, 100]