3个回答
展开全部
给你个画圆的例子
你参考一下
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int radius = 100;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(getmaxcolor());
/* draw the circle */
circle(midx, midy, radius);
/* clean up */
getch();
closegraph();
return 0;
}
你参考一下
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int radius = 100;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(getmaxcolor());
/* draw the circle */
circle(midx, midy, radius);
/* clean up */
getch();
closegraph();
return 0;
}
2008-02-15
展开全部
#include <windows.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
char arg[50]={0};
arg[0]= '\ " ';
strcpy(arg+1,argv[0]);
int len=int(strlen(arg));
arg[len]= '\ " ';
HWND hWnd=FindWindow(NULL,arg); //找到程序运行窗口的句柄
HDC hDC=GetDC(hWnd);//通过窗口句柄得到该窗口的设备场境句柄
HPEN hPen,hOldPen; //画笔
int i=0;
for(;i <500;++i)
SetPixel(hDC,10+i,10+i,0x0000ff);//用画点的办法画一根线,最后一个参数是颜色(32位)
hPen=CreatePen(PS_SOLID,2,0x00ff00);//生成绿色画笔
hOldPen=(HPEN)SelectObject(hDC,hPen);//把画笔引入设备场境
MoveToEx(hDC,20,50,NULL); //设置画线起点
LineTo(hDC,520,550); //画到终点
Arc(hDC,100,100,300,300,350,500,350,500);//画圆
SelectObject(hDC,hOldPen);
ReleaseDC(hWnd,hDC);
//下面是对比,表明它确实是控制台程序
printf( "hello console ");
system( "pause ");
return 0;
}
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
char arg[50]={0};
arg[0]= '\ " ';
strcpy(arg+1,argv[0]);
int len=int(strlen(arg));
arg[len]= '\ " ';
HWND hWnd=FindWindow(NULL,arg); //找到程序运行窗口的句柄
HDC hDC=GetDC(hWnd);//通过窗口句柄得到该窗口的设备场境句柄
HPEN hPen,hOldPen; //画笔
int i=0;
for(;i <500;++i)
SetPixel(hDC,10+i,10+i,0x0000ff);//用画点的办法画一根线,最后一个参数是颜色(32位)
hPen=CreatePen(PS_SOLID,2,0x00ff00);//生成绿色画笔
hOldPen=(HPEN)SelectObject(hDC,hPen);//把画笔引入设备场境
MoveToEx(hDC,20,50,NULL); //设置画线起点
LineTo(hDC,520,550); //画到终点
Arc(hDC,100,100,300,300,350,500,350,500);//画圆
SelectObject(hDC,hOldPen);
ReleaseDC(hWnd,hDC);
//下面是对比,表明它确实是控制台程序
printf( "hello console ");
system( "pause ");
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
如果用tc,有自己的绘图函数
用vc也有自己的画图方式
用vc也有自己的画图方式
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |