Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:112)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:112)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:112)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:112)
OrbWorks Community Forum • View topic - Chaos && Fractal

Chaos && Fractal

Share information about your software written for CE

Postby sydney on Tue Apr 06, 2004 9:48 am

I made them ... just for fun. :)


Code: Select all
//-------------------------------------------------------------------
// ALGO Feigenbaum.c
main()
{
   int i;
   float x,r;
   setpixelattr(255,255,255);
   menu_off();
   clearg();
   graph_on();
   setbrushattr(0,0,0);
   rect(0,0,240,295);
   keepscreen_on();

   for(r=2.5;r<4;r=r+0.005)
   {
      x=0.4;
      for (i=0;i<10;i++) x=x*r*(1-x);
      for (i=0;i<50;i++)
      {
         x=x*r*(1-x);
         setpixel(x*190+5,(r-2.5)*190+5);
      }
   }
}




//-------------------------------------------------------------------
// ALGO Lorentz.c
init()
{
   menu_off();
   clearg();
   setpixelattr(255,255,255);
   setbrushattr(148,148,148);
   rect(0,0,240,295);
   keepscreen_on();
}

main()
{
   float x,y,z,x1,y1,z1,dt;
   float a,b,c;
   int i;

   x=-15;y=0;z=0;
   dt=0.022;
   a=5;b=15;c=1;

   init();
   setpixelattr(255,255,255);
   for(i=0;i<7000;i++)
   {
      x1=x+(-a*x*dt)+(a*y*dt);
      y1=y+( b*x*dt)-(y*dt)-(z*x*dt);
      z1=z+(-c*z*dt)+(x*y*dt);
      if (i>50)
         line(x*12+120,320-z*12,x1*12+120,320-z1*12);
      x=x1;y=y1;z=z1;
   }
}



//-------------------------------------------------------------------
//ALGO Mandelbrot.c
init()
{
   setpixelattr(255,255,255);
   menu_off();
   clearg();
   setbrushattr(128,128,128);
   rect(0,0,240,295);
   keepscreen_on();
}

main()
{
   int i,c;
   float x,y,a,b,a1,b1;

   init();
   for(x=-2.5;x<1.5;x=x+0.02)
      for(y=-2;y<2;y=y+0.02)
      {
         a=0;b=0;
         for(i=0;i<16;i++)
         {
            a1=a*a-b*b+x;
            b1=2*a*b+y;
            a=a1;b=b1;
            if (abs(a)>3 || abs(b)>3) break;
         }
         c=16*i;
         setpixelattr(c,c,c+64);
         setpixel(x*50+145,y*50+140);
      }
}



//-------------------------------------------------------------------
//ALGO Mandelbrot^3
init()
{
   setpixelattr(255,255,255);
   menu_off();
   clearg();
   setbrushattr(128,128,128);
   rect(0,0,240,295);
   keepscreen_on();
}

main()
{
   int i,c;
   float x,y,a,b,a1,b1;

   init();
   for(x=-2;x<2;x=x+0.02)
      for(y=-2;y<2;y=y+0.02)
      {
         a=0;b=0;
         for(i=0;i<16;i++)
         {
            a1=a*a*a-a*b*b-2*a*b*b+x;
            b1=a*a*b-b*b*b+2*a*a*b+y;
            a=a1;b=b1;
            if (abs(a)>2 || abs(b)>2) break;
         }
         c=16*i;
         setpixelattr(c,c,c+64);
         setpixel(x*50+120,y*50+140);
      }
}



//-------------------------------------------------------------------
//ALGO Newton^3.c
init()
{
   setpixelattr(255,255,255);
   menu_off();
   clearg();
   setbrushattr(190,190,190);
   rect(0,0,240,295);
   keepscreen_on();
}

float dist(float x,float y)
{
   float d;
   d=x*x+y*y;
return d;
}

main()
{
   int i;
   float nx,ny,x,y,x1,y1,cm;
   float r;
   r=sqrt(3);

   init();
   for(nx=-100;nx<100;nx++)
   {
      for(ny=-100;ny<100;ny++)
      {
         x=nx/100; y=ny/100;
         for(i=0;i<30;i++)
         {
            if(nx==0 && ny==0) break;
            cm=3*dist(x,y)*dist(x,y);
            x1=2*x/3+(x*x-y*y)/cm;
            y1=2*y/3-2*x*y/cm;
            x=x1;y=y1;
         }
         if(!(nx==0 && ny==0))
         {
            if(dist(x-1,y)<0.03)
            {
               setpixelattr(200,0,0);
               setpixel(nx+120,120-ny);
            }
            if(dist(x+0.5,y-r/2)<0.03)
            {
               setpixelattr(200,160,0);
               setpixel(nx+120,120-ny);
            }
            if(dist(x+0.5,y+r/2)<0.03)
            {
               setpixelattr(0,0,200);
               setpixel(nx+120,120-ny);
            }
         }
      }
   }
}



//-------------------------------------------------------------------
//ALGO lifeGame.c
init()
{
   menu_off();
   clearg();
   keepscreen_on();
}

drawpool(int pool)
{
   int x,y,n;

   for(x=0;x<20;x++)
   {
      for(y=0;y<20;y++)
      {
         n=x*20+y;
         if(pool[n]) setbrushattr(64,128,255);
         else setbrushattr(255,255,255);
         rect(x*10+20,y*10+10,30+x*10,20+y*10);
      }
   }   
}

setpool_1(int pool)
{
   int i;
   for (i=1;i<19;i++) pool[10*20+i]=1;
   pool[10*20+10]=0;
}

setpool(int pool)
{
   int x,y,n;
   for(x=0;x<20;x++)
   {
      for(y=0;y<20;y++)
      {
         n=x*20+y;
         if (rand()<0.02) pool[n]=1;
      }
   }
}

int getinfo(int x, int y, int pool)
{
   int t,a,b;
   t=0;

   a=x-1;b=y;
   if(a>=0)
      if((pool[a*20+b])) t++;

   a=x+1;b=y;
   if(a<20)
      if((pool[a*20+b])) t++;

   a=x;b=y-1;
   if(b>=0)
      if((pool[a*20+b])) t++;

   a=x;b=y+1;
   if(b<20)
      if((pool[a*20+b])) t++;

   a=x-1;b=y-1;
   if(a>=0 && b>=0)
      if((pool[a*20+b])) t++;

   a=x+1;b=y+1;
   if(a<20 && b<20)
      if((pool[a*20+b])) t++;

   a=x+1;b=y-1;
   if(a<20 && b>=0)
      if((pool[a*20+b])) t++;

   a=x-1;b=y+1;
   if(a>=0 && b<20)
      if((pool[a*20+b])) t++;

return t;
}

core(int pool)
{
   int swap[400];
   int x,y,n,t;

   for(x=0;x<20;x++)
   {
      for(y=0;y<20;y++)
      {
         n=x*20+y;
         t=getinfo(x,y,pool);
         swap[n]=0;
         if (t==3) swap[n]=1;
         if (t==2 && pool[n]==1) swap[n]=1;
      }
   }

   for(x=0;x<400;x++) pool[x]=swap[x];
}

main()
{
   int pool[400];
   int i;

   init();
   setpool_1(pool);
   setpool(pool);

   for(i=0;i<255;i++)
   {
      drawpool(pool);
      core (pool);
   }
}


sydney
 
Posts: 2
Joined: Tue Apr 06, 2004 9:24 am

Postby sydney on Tue Apr 06, 2004 9:58 am

you will see speed is a problem :oops: [:p] :x
sydney
 
Posts: 2
Joined: Tue Apr 06, 2004 9:24 am


Return to CE Software

Who is online

Users browsing this forum: No registered users and 2 guests

cron