没有合适的资源?快使用搜索试试~ 我知道了~
Midpoint中点画直线
需积分: 10 4 下载量 173 浏览量
2011-11-10
09:03:22
上传
评论
收藏 4KB TXT 举报
温馨提示
![preview](https://dl-preview.csdnimg.cn/txt_preview/3777049/3777049_thumbnail_1.jpg?x-oss-process=style/thumbnail)
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
试读
8页
Midpoint中点画直线
资源推荐
资源详情
资源评论
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
/* WIN-TC BGI 图形编程模板 */
#include "Conio.h"
#include "graphics.h"
#define closegr closegraph
void initgr(void) /* BGI初始化 */
{
int gd = DETECT, gm = 0; /* 和gd = VGA,gm = VGAHI是同样效果 */
registerbgidriver(EGAVGA_driver);/* 注册BGI驱动后可以不需要.BGI文件的支持运行 */
initgraph(&gd, &gm, "");
}
void Midpointline1(int x1,int y1,int x2,int y2,int color)
{
int d,d1,d2,x,y,i,temp,a1=x1,b1=y1,a2=x2,b2=y2;
if(x1<x2);
else
{
temp=a1;
a1=a2;
a2=temp;
temp=b1;
b1=b2;
b2=temp;
}
d=(b2-b1)*(2*a1+2)+2*(a2*b1-a1*b2)-(a2-a1)*(2*b1+1);
d1=2*(b2-b1)-2*(a2-a1);
d2=2*(b2-b1);
x=a1;
y=b1;
#include "Conio.h"
#include "graphics.h"
#define closegr closegraph
void initgr(void) /* BGI初始化 */
{
int gd = DETECT, gm = 0; /* 和gd = VGA,gm = VGAHI是同样效果 */
registerbgidriver(EGAVGA_driver);/* 注册BGI驱动后可以不需要.BGI文件的支持运行 */
initgraph(&gd, &gm, "");
}
void Midpointline1(int x1,int y1,int x2,int y2,int color)
{
int d,d1,d2,x,y,i,temp,a1=x1,b1=y1,a2=x2,b2=y2;
if(x1<x2);
else
{
temp=a1;
a1=a2;
a2=temp;
temp=b1;
b1=b2;
b2=temp;
}
d=(b2-b1)*(2*a1+2)+2*(a2*b1-a1*b2)-(a2-a1)*(2*b1+1);
d1=2*(b2-b1)-2*(a2-a1);
d2=2*(b2-b1);
x=a1;
y=b1;
putpixel(x,y,color);
for(i=0;i<(a2-a1);i++)
if(d>0)
{
d=d+d1;
putpixel(++x,++y,color);
}
else
{
d=d+d2;
putpixel(++x,y,color);
}
}
void Midpointline2(int x1,int y1,int x2,int y2,int color)
{
int d,d1,d2,x,y,i,temp,a1=x1,b1=y1,a2=x2,b2=y2;
if(x1<x2);
else
{
temp=a1;
a1=a2;
a2=temp;
temp=b1;
b1=b2;
b2=temp;
}
d=(b2-b1)*(2*a1+2)+2*(a2*b1-a1*b2)-(a2-a1)*(2*b1-1);
d1=2*(b2-b1)+2*(a2-a1);
d2=2*(b2-b1);
for(i=0;i<(a2-a1);i++)
if(d>0)
{
d=d+d1;
putpixel(++x,++y,color);
}
else
{
d=d+d2;
putpixel(++x,y,color);
}
}
void Midpointline2(int x1,int y1,int x2,int y2,int color)
{
int d,d1,d2,x,y,i,temp,a1=x1,b1=y1,a2=x2,b2=y2;
if(x1<x2);
else
{
temp=a1;
a1=a2;
a2=temp;
temp=b1;
b1=b2;
b2=temp;
}
d=(b2-b1)*(2*a1+2)+2*(a2*b1-a1*b2)-(a2-a1)*(2*b1-1);
d1=2*(b2-b1)+2*(a2-a1);
d2=2*(b2-b1);
剩余7页未读,继续阅读
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/abf59f0c5b2a4e099e4cf4a0f09c8c82_shaoyang200853.jpg!1)
shaoyang200853
- 粉丝: 0
- 资源: 17
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)