RSS Forums RSS

please help, this is what i have done so far

Please support our C++ advertiser: Programming Forums
Thread Solved
Reply
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

  #1  
Nov 21st, 2008
 


#include <conio.h>
#include <graphics.h>
#include <math.h>
#include <stdlib.h>
#include <dos.h>
void serp(int level, int Ax, int Ay, int Bx, int By)
{
	int poly[4]={Ax,Ay,Bx,By};

	setfillstyle(SOLID_FILL,YELLOW);

	if (level>0)
	{

		serp(level-1, Ax,Ay ,(2*Ax+Bx)/3,(2*Ay+By)/3);
		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);
		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);
		serp(level-1,(Ax+2*Bx)/3,(Ay+2*By)/3,Bx,By);
        }
	else fillpoly(2,poly);
}

int main(void)
{
	int graphdriver=DETECT, graphmode;
	initgraph(&graphdriver, &graphmode, "");

	int i, N=8, Bx=0, By=235, Ax=635, Ay=235;

	for (i=0; i<N; i++)
	{

	serp(0,Ax,Ay,Bx,By);

	serp(1,Ax,Ay,Bx,By);
	serp(2,Ax,Ay,Bx,By);
	serp(3,Ax,Ay,Bx,By);
	serp(4,Ax,Ay,Bx,By);
	serp(5,Ax,Ay,Bx,By);
	serp(6,Ax,Ay,Bx,By);
	serp(7,Ax,Ay,Bx,By);

	delay(1000);
	cleardevice();
	}

	getch();
	closegraph();
	return 0;
}

what i could like to know is how do i fill each object with different colours?
AddThis Social Bookmark Button
Reply With Quote  
Posts: 314
Reputation: cikara21 is an unknown quantity at this point 
Solved Threads: 61
cikara21's Avatar
cikara21 cikara21 is offline Offline
Posting Whiz

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

  #2  
Nov 22nd, 2008
I don't test it yet ..Try it..
setfillstyle(SOLID_FILL,level);
// or
fillpoly(level,poly);
.:-cikara21-:.
Reply With Quote  
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

  #3  
Nov 22nd, 2008
thanks for your help
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Other Threads in the C++ Forum
Views: 324 | Replies: 2 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 10:41 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC