home *** CD-ROM | disk | FTP | other *** search
/ CD Action 56 / cdaction-56.iso / Bonus / C.exe / cz9 / naCD / Julia2 / Julia2.cpp next >
C/C++ Source or Header  |  2000-11-12  |  1KB  |  62 lines

  1. # include <complex.h>
  2. # include <conio.h>
  3. # include <stdio.h>
  4. # include <pc.h>
  5. # include <allegro.h>
  6. # include <time.h>
  7.  
  8. clock_t s,e;
  9.  
  10. BITMAP* bufor;
  11. int cx=0, cy=0;
  12.  
  13. void RysujJulie()
  14. {
  15.   int i,j,px,py;
  16.   int xn,yn,x2,y2,x,y;
  17.   unsigned char c;
  18.   for (i=-1920,px=0;i<1920;i+=6,px++)
  19.     for (j=-1920,py=0;j<1920;j+=8,py++)
  20.     {
  21.       c=0;
  22.       x=i;y=j;
  23.       x2=x*x;
  24.       y2=y*y;
  25.       while (((x2+y2)<4000000) && (c<31))
  26.       {
  27.         c++;
  28.         y=((x*y)>>9)+cy;
  29.         x=((x2-y2)>>10)+cx;
  30.         x2=x*x;
  31.         y2=y*y;
  32.       }
  33.     ((short int *)bufor->line[py])[px]=makecol16(8*c,8*c,255-c);
  34.     }
  35.     blit(bufor, screen, 0, 0, 0, 0, 640, 480);
  36. }
  37.  
  38. int main()
  39. {
  40.    int err;
  41.  
  42.    allegro_init();
  43.    set_color_depth(16);
  44.    if ((err=set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0))<0)
  45.    {
  46.      printf("Error: %s\n",allegro_error);
  47.      return(1);
  48.    }
  49.    bufor = create_bitmap(640, 480);
  50.  
  51.    s = clock();
  52.    RysujJulie();
  53.    e = clock();
  54.  
  55.    getch();
  56.  
  57.    destroy_bitmap(bufor);
  58.    textmode(3);
  59.    printf("Czas rysowania: %2.2f sec.\n", (double)(e-s)/CLOCKS_PER_SEC);
  60.    getch();
  61. }
  62.