画线算法(使用加减法)
来源:互联网 发布:知乎 惊悚悬疑电影 编辑:程序博客网 时间:2024/05/17 04:18
// 画线函数
// 梅文海
// 2005.11.29
void Line2(CDC* ADC,int x1,int y1,int x2,int y2,COLORREF AColor)
{
int iW,iH;
int x,y;
iW=abs(x1-x2); // 宽
iH=abs(y1-y2); // 高
int iYAdd=1;
if(x2<x1){ // 调整 Y 的方向
x=x2;
y=y2;
if(y1<y2){
iYAdd=-1;
}
}
else{
x=x1;
y=y1;
if(y2<y1){
iYAdd=-1;
}
}
int iCount=iH; // 高宽的最大者
if(iW>iH){
iCount=iW;
}
int iXCount=0;
int iYCount=0;
ADC->SetPixel(x,y,AColor);
for(int i=0;i<iCount-1;i++){
iXCount+=iW;
iYCount+=iH;
if(iXCount>=iCount){
x++;
iXCount-=iCount;
}
if(iYCount>=iCount){
y+=iYAdd;
iYCount-=iCount;
}
ADC->SetPixel(x,y,AColor);
}
}
凌丽软件 http://www.wosens.com
- 画线算法(使用加减法)
- 【OpenGL】使用DDA算法画线
- 画线算法
- 画线算法-Bresenham算法
- Bresenham 画线算法
- Bresenham高效画线算法
- Bresenham 画线算法
- Bresenham 画线算法
- DDA画线算法
- Breshame画线算法
- Bresenham 画线算法
- 画线算法的实现
- Bresenham画线算法
- dda画线算法实现
- 中点画线算法
- Bresenham 画线算法
- Bresenham高效画线算法
- Bresenham高效画线算法
- 使用MIDP2.0开发游戏(6)设计Clock
- 你博我也博
- Java开源思想&技术--xlSQL (关键字: Excel,Java,SQL)
- 使用sunjce加密解密问题解决
- google的一道JAVA面试题!!! (转)
- 画线算法(使用加减法)
- java sdk standard edition(j2se)安装小记
- 开发出高性能的网站,第二部分 — 最佳缓冲控制(转)
- 使用MIDP2.0开发游戏(7)设计Scheduler
- 使用ASPxGrid 2.5
- 搜索引擎设计实用教程(4)-以百度为例
- 打开IE窗口时最大化
- on the IDOL route to be a researchere in student's days
- 开发出高性能的网站,第三部分:压缩和其他服务器端的技术(转)