Read-only archive. Login and posting are unavailable.
Closed Thread
 
Thread Tools
  #1  
Old 17-01-2010, 16:04
JACKIECHUN's Avatar
K.I.A
Join Date: 04-2008
Posts: 262
Help Lập trình c for Dos

Ai biết vẽ lá cờ việt nam bằng thuật toán bresenham. Và tô màu thì giúp em với
  #2  
Old 17-01-2010, 16:13
huuhau's Avatar
Đã tốn tiền
Join Date: 11-2007
Posts: 407
Re: Help Lập trình c for Dos

Quote:
Originally Posted by JACKIECHUN View Post
Ai biết vẽ lá cờ việt nam bằng thuật toán bresenham. Và tô màu thì giúp em với
Bresenham là thuật toán gì quên rồi? Lục lại đống bài cũ thì được hàm này. Bạn nghiên cứu xem, mình cũng quên ráo rồi. Chả biết sao code dc vậy nữa


Code:
#define RAD(goc) ((goc)*(M_PI/180.0))
//xc, yc là tâm ngôi sao, truyền dgoc vào để ngôi sao xoay được, colorentry là struct chứa 3 màu
void DrawStar(int xc, int yc, int R,int dgoc,colorentry c)
{
	DrawCircle(xc,yc,R,c);
	float a = RAD(90-72);
	float r = R/3.0;//tan(RAD(36));
	float dr[]= {R,r};
	float da[]={a,a+M_PI/5};
	glBegin(GL_LINE_LOOP);
	
		glColor3ub(c.red,c.green,c.blue);
		for(int j = 0 ;j < 5; j++)
			for(int i = 0 ;i < 2 ; i++)
			{
				float x = xc + dr[i] * cos(da[i]+j*2*M_PI/5.0-RAD(dgoc));
				float y = yc + dr[i] * sin(da[i]+j*2*M_PI/5.0-RAD(dgoc));
				glVertex2d(x,y);
			}
	
	glEnd();
}
void FillStar(int xc, int yc, int R,  colorentry c,int dgoc)
{	
	float a = RAD(54);
	float r = R/3.0;//*tan(RAD(36));
	float dr[]= {r,R};
	float da[]={a,a+M_PI/5};
	glBegin(GL_TRIANGLE_FAN);
	{
	glColor3ub(c.red,c.green,c.blue);
	for(int j = 0 ;j < 5; j++)
		for(int i = 0 ;i < 2 ; i++)
		{
			float x = xc + dr[i] * cos(da[i]+j*2*M_PI/5.0-RAD(dgoc));
			float y = yc + dr[i] * sin(da[i]+j*2*M_PI/5.0-RAD(dgoc));
			glVertex2d(x,y);
		}
	}
	glEnd();

}
  #3  
Old 17-01-2010, 17:01
JACKIECHUN's Avatar
K.I.A
Join Date: 04-2008
Posts: 262
Re: Help Lập trình c for Dos

Cảm ơn bạn. Nhung mình cần thuật toán bresham co cai này thì mình cũng có
Closed Thread

« Previous Thread | Next Thread »

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT +7. The time now is 13:59.