Chinaunix首页 | 论坛 | 博客
  • 博客访问: 532668
  • 博文数量: 150
  • 博客积分: 5010
  • 博客等级: 大校
  • 技术积分: 1861
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-17 00:19
文章分类

全部博文(150)

文章存档

2011年(1)

2009年(14)

2008年(135)

我的朋友

分类: LINUX

2008-05-26 15:33:40

在LCD驱动中添加了画圆的函数,采用中点法进行迭代:我同学的程序,真有思想!

有圆的对称,判别式等,只是用到的点从(0,R)到(x=y)的坐标。参考有:

中点法,很好。


/*********************************************************************************************

* name:  lcd_draw_circle()

* func:  Draw circle with appointed color

* para:  

*   ucColor -- appointed color value

* ret:  none

* modify:

* comment:  

*********************************************************************************************/

void  lcd_draw_circle(UINT16T usX, UINT16T usY, UINT16T usR, UINT8T usColor)

{

 /* using midpoint method to draw the circle */

 INT16T x, y;

 INT16T f;

 

 x = 0;

 y = usR;

 f = 1 - usR;

 LCD_PutPixel(usX+x, usY+y, usColor);

 while(x<=y)

 {

  if(f<0)

   f += x*2 + 3;

  else

  {

   f += (x-y)*2 + 5;

   --y;

  }

  ++x;

  LCD_PutPixel(usX+x, usY+y, usColor); /* 2th division */

  LCD_PutPixel(usX-x, usY+y, usColor); /* 3th division */

  LCD_PutPixel(usX+y, usY+x, usColor); /* 1th division */

  LCD_PutPixel(usX-y, usY+x, usColor); /* 4th division */

  LCD_PutPixel(usX-x, usY-y, usColor); /* 6th division */

  LCD_PutPixel(usX+x, usY-y, usColor); /* 7th division */

  LCD_PutPixel(usX-y, usY-x, usColor); /* 5th division */

  LCD_PutPixel(usX+y, usY-x, usColor); /* 8th division */

 }

}

阅读(1489) | 评论(0) | 转发(0) |
0

上一篇:QT读写文件

下一篇:us0s lcd显示:问题

给主人留下些什么吧!~~