please help, this is what i have done so far

Thread Solved
Reply

Join Date: Nov 2008
Posts: 3
Reputation: bids is an unknown quantity at this point 
Solved Threads: 0
bids bids is offline Offline
Newbie Poster

please help, this is what i have done so far

 
0
  #1
Nov 21st, 2008
  1.  
  2.  
  3.  
  4. #include <conio.h>
  5. #include <graphics.h>
  6. #include <math.h>
  7. #include <stdlib.h>
  8. #include <dos.h>
  9. void serp(int level, int Ax, int Ay, int Bx, int By)
  10. {
  11. int poly[4]={Ax,Ay,Bx,By};
  12.  
  13. setfillstyle(SOLID_FILL,YELLOW);
  14.  
  15. if (level>0)
  16. {
  17.  
  18. serp(level-1, Ax,Ay ,(2*Ax+Bx)/3,(2*Ay+By)/3);
  19. serp(level-1,(2*Ax+Bx)/3,(2*Ay+By)/3,(Ax+Bx)/2+sqrt(3)*(Ay-By)/6,(Ay+By)/2+sqrt(3)*(Bx-Ax)/6);
  20. serp(level-1,(Ax+Bx)/2+sqrt(3)*(Ay-By)/6,(Ay+By)/2+sqrt(3)*(Bx-Ax)/6,(Ax+2*Bx)/3,(Ay+2*By)/3);
  21. serp(level-1,(Ax+2*Bx)/3,(Ay+2*By)/3,Bx,By);
  22. }
  23. else fillpoly(2,poly);
  24. }
  25.  
  26. int main(void)
  27. {
  28. int graphdriver=DETECT, graphmode;
  29. initgraph(&graphdriver, &graphmode, "");
  30.  
  31. int i, N=8, Bx=0, By=235, Ax=635, Ay=235;
  32.  
  33. for (i=0; i<N; i++)
  34. {
  35.  
  36. serp(0,Ax,Ay,Bx,By);
  37.  
  38. serp(1,Ax,Ay,Bx,By);
  39. serp(2,Ax,Ay,Bx,By);
  40. serp(3,Ax,Ay,Bx,By);
  41. serp(4,Ax,Ay,Bx,By);
  42. serp(5,Ax,Ay,Bx,By);
  43. serp(6,Ax,Ay,Bx,By);
  44. serp(7,Ax,Ay,Bx,By);
  45.  
  46. delay(1000);
  47. cleardevice();
  48. }
  49.  
  50. getch();
  51. closegraph();
  52. return 0;
  53. }

what i could like to know is how do i fill each object with different colours?
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 320
Reputation: cikara21 is an unknown quantity at this point 
Solved Threads: 63
cikara21's Avatar
cikara21 cikara21 is offline Offline
Posting Whiz

Re: please help, this is what i have done so far

 
0
  #2
Nov 22nd, 2008
I don't test it yet ..Try it..
  1. setfillstyle(SOLID_FILL,level);
  2. // or
  3. fillpoly(level,poly);
.:-cikara21-:.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 3
Reputation: bids is an unknown quantity at this point 
Solved Threads: 0
bids bids is offline Offline
Newbie Poster

Re: please help, this is what i have done so far

 
0
  #3
Nov 22nd, 2008
thanks for your help
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC