31 oct 2007

Fractals with Asymptote – fig0080

Catégorie : Asymptote, Examples 2D, FractalsPh. Ivaldi @ 4 h 53 min

Figure 0008
(Compiled with Asymptote version 1.87svn-r4652)
    
size(10cm,0);

real mandelbrot(pair c, real r, int count=100) {
  int i=0;
  pair z=c;
  do {
    ++i;
    z=z^2+c;
  } while (length(z) <= r && i<count);

  return (i<count) ? i/count : 0;
}

real r=4;
real step=.01;
real xmin=-2.25, xmax=.75;
real ymin=-1.3, ymax=0;

real x=xmin, y=ymin;
int xloop=round((xmax-xmin)/step);
int yloop=round((ymax-ymin)/step);
pen p;
path sq=scale(step)*unitsquare;

for(int i=0; i < xloop; ++i) {
  for(int j=0; j < yloop; ++j) {
    p=mandelbrot((x,y),r,20)*red;
    filldraw(shift(x,y)*sq,p,p);
    y += step;
  }
  x += step;
  y=ymin;
}

add(reflect((0,0),(1,0))*currentpicture);

  • del.icio.us
  • Facebook
  • Google Bookmarks
  • TwitThis
  • Digg
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati

Mots-clefs : , ,

Laisser une réponse

Thank you to place all source code between the tags [code] and [/code]