VC++高手请进,高分求购代码

evaiou 2001-07-23 06:01:29
求教类似于Autocad中直线的画法的VC++的代码,主要部分也可,最好有一定的解释
...全文
110 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
jisheng 2001-07-29
  • 打赏
  • 举报
回复
呵呵,在dos下的???
lanzhengpeng2 2001-07-29
  • 打赏
  • 举报
回复
#include <stdlib.h>
#include <conio.h>
#include <graphics.h>
#include <math.h>

void init(void)
{
int ndriver = VGA;
int nmode = VGAHI;
initgraph(&ndriver,&nmode,NULL);

}
//x0 must .lt. x1 and y0 must .lt. y1
void Integer_Bresenham_Line_1(register int x0,register int y0,register int x1,int y1,int color)
{
int e,dy2,dx2;
e = x1 - x0;
dy2 = y1 - y0 + y1 - y0;
dx2 = e + e;
e = -e;
for(; x0 <= x1; x0++)
{
putpixel(x0,y0,color);
e += dy2;
if( e > 0)
{
y0 += 1;
e -= dx2;
}
}
}
//x0 must .lt. x1 and y0 must .gt. y1
void Integer_Bresenham_Line_2(register int x0,register int y0,register int x1,int y1,int color)
{
int e,dy2,dx2;
e = x1 - x0;
dy2 = y1 - y0 + y1 - y0;
dx2 = e + e;
e = -e;
for(; x0 <= x1; x0++)
{
putpixel(x0,y0,color);
e += dy2;
if( e < 0)
{
y0 -= 1;
e += dx2;
}
}
}
//y0 must .lt. y1
void Integer_Bresenham_Line_X(int x,int y0,int y1,int color)
{
for( ;y0 <= y1; y0++)
{
putpixel(x,y0,color);
}
}
//x0 must .lt. x1
void Integer_Bresenham_Line_Y(int x0,int x1,int y,int color)
{
for( ;x0 <= x1; x0++)
{
putpixel(x0,y,color);
}
}
void Integer_Bresenham_Line(int x0,int y0,int x1,int y1,int color)
{
int t;
if(x0 == x1)
{
(y0 < y1) ? Integer_Bresenham_Line_X(x0,y0,y1,color) : Integer_Bresenham_Line_X(x0,y1,y0,color);
}
else if(x0 > x1)
{
t = x0,x0 = x1,x1 = t,t = y0,y0 = y1,y1 = t;
}
if(y0 == y1)
{
(x0 < x1) ? Integer_Bresenham_Line_Y(x0,x1,y0,color) : Integer_Bresenham_Line_Y(x1,x0,y0,color);
}
else
{
(y0 < y1) ? Integer_Bresenham_Line_1(x0,y0,x1,y1,color) : Integer_Bresenham_Line_2(x0,y0,x1,y1,color);
}
}
void main(void)
{
init();
setcolor(15);
Integer_Bresenham_Line(0,480,640,0,3);
getch();
line(0,480,640,0);
getch();
}

TC++30中编译通过!
evaiou 2001-07-28
  • 打赏
  • 举报
回复
是用“橡皮筋”来画直线
e有详细的代码吗
evaiou 2001-07-28
  • 打赏
  • 举报
回复
是用“橡皮筋”来画直线
supersusheng 2001-07-25
  • 打赏
  • 举报
回复
给我联系,我有vb和vc的两种代码。实际上很容易编,没必要送分
FlyOverSea 2001-07-25
  • 打赏
  • 举报
回复
use pen
FlyOverSea 2001-07-25
  • 打赏
  • 举报
回复
use pen
Suddy 2001-07-25
  • 打赏
  • 举报
回复
你知道你要动态显示临时的线,是不是,设置PEN的属性就行了
Matrix_w 2001-07-25
  • 打赏
  • 举报
回复
line()函数不可以吗?
evaiou 2001-07-25
  • 打赏
  • 举报
回复
可我怎么和你联系,我不知道你的地址
ShyWJB 2001-07-24
  • 打赏
  • 举报
回复
Autocad在学校只用过2.62版的,以后看别人用过R14版的,依稀记得好象是用“橡皮筋”来画直线,
如果是这种方法画直线,其实很多书上都有介绍,如果是画直线的算法,可以找本图形方面的书看看。

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧