GRY-Online.pl --> Archiwum Forum

Fraktale w C++

22.11.2001
18:07
smile
[1]

czarny [ Pretorianin ]

Fraktale w C++

Czy ktoś mógłby mi napisać jakich komend potrzebuje do napisania programu rysującego fraktale z kropek rekurencyjnie .A może kawałeczek kodu.

22.11.2001
21:12
[2]

MOD [ Generaďż˝ ]

Wydaje mi sie ze to o co ci chodzi z cd action: # include <stdio.h> # include <pc.h> # include <allegro.h> BITMAP *buf; PALETTE pal; int x[3]=‹0,0,640›,y[3]=‹0,480,0›; int xp,yp; char los; int main() ‹ int err; allegro_init(); install_timer(); install_mouse(); set_color_depth(16); if ((err=set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0))<0) ‹ printf("Error: %s\n",allegro_error); return(1); › buf = create_bitmap(640,480); clear(buf); xp=rand()%640; yp=rand()%480; while (!kbhit()) ‹ los = rand()%3; xp=abs((x[los]+xp)/2); yp=abs((y[los]+yp)/2); ((short *)buf->line[yp])[xp]=makecol16(255-(xp/3),yp/2,xp/3); blit(buf, screen, xp, yp, xp, yp, 1, 1); › destroy_bitmap(buf); text_mode(0); ›

22.11.2001
21:13
[3]

MOD [ Generaďż˝ ]

i jeszcze jedno # include <stdio.h> # include <allegro.h> # include <pc.h> # define c1 255 # define xe 640 # define ye 480 BITMAP* bufor; PALETTE pal; // funkcja sprawdza, czy w otoczeniu punktu (x,y) znajduje sie // punkt nalezacy do roslinki int testp(BITMAP* buf, int x, int y) ‹ int r=0; if (getg16(((short *)buf->line[y-1])[x-1])==c1 || getg16(((short *)buf->line[y-1])[x])==c1 || getg16(((short *)buf->line[y-1])[x+1])==c1 || getg16(((short *)buf->line[y])[x-1])==c1 || getg16(((short *)buf->line[y])[x+1])==c1 || getg16(((short *)buf->line[y+1])[x-1])==c1 || getg16(((short *)buf->line[y+1])[x])==c1 || getg16(((short *)buf->line[y+1])[x+1])==c1) r=1; return r; › // przeprowadza symulacje osadzania elektrolitycznego void drawosad(BITMAP* buf) ‹ int i,j,c; int x,y; // gradient w tle for (i=ye-1;i>=0;i--) for (j=0;j<xe;j++) ((short *)buf->line[i])[j]=makecol16(0,0,i/2); // zaczatek osadu, uwaga na c1 for (i=0;i<xe;i++) ((short *)buf->line[ye-5])[i]=makecol16(c1/2,c1,0); blit(buf, screen, 0, 0, 0, 0, xe, ye); // wyrzucaj czastki while (!kbhit()) ‹ x=1+rand()%(xe-2); y=1; c=1; while(c) ‹ if (testp(buf, x, y)) ‹ c=0; ((short *)buf->line[y])[x]=makecol16(y>>3,c1,y>>3); blit(buf, screen, x, y, x, y, 1, 1); › x+=2*(rand()%2)-1; if (x<1) x=1; if (x>xe-2) x=xe-2; y+=1; if (y>ye-2) c=0; › › getch(); › int main() ‹ allegro_init(); install_timer(); install_mouse(); set_color_depth(16); set_gfx_mode(GFX_AUTODETECT, xe, ye, 0, 0); bufor=create_bitmap(xe, ye); clear(bufor); clear(screen); drawosad(bufor); destroy_bitmap(bufor); text_mode(3); return 0; ›

22.11.2001
21:14
[4]

MOD [ Generaďż˝ ]

i jeszcze # include <stdio.h> # include <pc.h> # include <allegro.h> # include <math.h> BITMAP *buf; void SkalowanySierp() ‹ int x,y; clear(buf); for (x=0;x<640;x++) for (y=0;y<480;y++) if (x & y) ((short *)buf->line[y])[x]=makecol16(255-(x/3),y/2,x/3); blit(buf, screen, 0, 0, 0, 0, 640, 480); › int main() ‹ int err; allegro_init(); install_timer(); install_mouse(); set_color_depth(16); if ((err=set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0))<0) ‹ printf("Error: %s\n",allegro_error); return(1); › buf = create_bitmap(640,480); SkalowanySierp(); while (!kbhit()); destroy_bitmap(buf); text_mode(0); ›

© 2000-2024 GRY-OnLine S.A.