943,735 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 408
  • C++ RSS
Nov 15th, 2008
0

How do i put colour into this program help please

Expand Post »
#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); not working the way i want.

	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;
}
i want to make other other shapes in different colours
Last edited by Ancient Dragon; Nov 15th, 2008 at 2:57 pm. Reason: add code tags
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bids is offline Offline
3 posts
since Nov 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: problem with class static member.
Next Thread in C++ Forum Timeline: Visual c++ problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC