c语言画线化图形知识点

void setlinecolor(COLORREF color);            //设置线条描边颜色
cleardevice();                        //清屏操作
void setorigin(int x,inty);                        //int x int y表示远点在物理坐标上的x和y坐标
void setaspectratio(float xasp, float yasp);    //float xasp在x方向上的缩放因子float yasp,在y方向上的缩放因子
void putpixel(int x, int y, COLORREF color);    //像素点的绘制
void line(int x1,int y1,int x2,int y2);            //画直线(x1,y1)起始坐标(y1,y2)终点坐标 
void rectangle(int left,int top,int right,int bottom);    //(left,top)矩形左上角坐标,(right,bottom)矩形右下角坐标
void ellipse(int left,int top,int right,int bottom);    //(left,top)内切圆矩形左上角坐标,(right,bottom)内切圆矩形右下角坐标
void roundrect(int left,int top,int right,int bottom,int ellipsewidth);//(left,top)圆角矩形左上角坐标,(right,bottom)圆角矩形右下角坐标,
                                                                        ellipsewidth表示构成圆角矩形的圆角的椭圆宽度,
                                                                        ellipseheight表示构成圆角矩形的圆角的椭圆高度
void pie(//绘制扇形
    int left,
    int top,
    int right,
    int bottom
    double stangle,//扇形的起始角度的弧度
    double endangle//扇形的终止的弧度
);
void arc(//绘制圆弧
    int left,
    int top,
    int right,
    int bottom
    double stangle,//圆弧的起始角度的弧度
    double endangle//圆弧的终止角的弧度
);

绘制多边形(封闭的)
void polygon(
    const POINT *points,//POINT类型的指针,指向结构POINT数组的首元素表示每个点的坐标
    int num                //表示数组中有多少个元素
);
绘制不封闭的图形
void polyline(
    const POINT *points,//POINT类型的指针,指向结构POINT数组的首元素表示每个点的坐标
    int num                //表示数组中有多少个元素
);
//播放音乐
MCIEROR mciSendString(
        LPCTSTR lpszCommand,//mci命令符
        LPTSTR lpszReturnString,//null
        UINT cchReturn,            //0
        HANDLE hwndCallback     //null
    );

总结
播放音乐    mciSendString
绘制点        putpixel
绘制直线    line
绘制圆        circle
绘制矩形    retangle
绘制椭圆    ellipse
绘制圆角矩形roundrect
绘制扇形    pie
绘制圆弧    arc

绘制多边形
polygon    函数绘制封闭的函数
polyline函数绘制不封闭的图形

void main() {
	initgraph(WIDTH, HEIGHT);

	//以物理坐标为准设置逻辑坐标的原点
	setorigin(200, 200);
	//x,y轴的反转 -1y轴旋转一百八十度,相当于数学中的坐标系
	setaspectratio(1, -1);
	//设置线条描边颜色
	setlinecolor(RED);
	//绘制像素点,
	putpixel(0, 0, RED);
	//画直线,坐标轴
	line(-100, 0, 100, 0);
	line(0, 100, 0, -100);
	//画矩形
	rectangle(0, 0, 100, -100);
	//画矩形的内切圆
	ellipse(0, 0, 100, -100);
	//绘制圆角矩形
	roundrect(100, 100, -100, -100, 100, 100);
	//绘制扇形
	pie(-200, 200, -100, 100, 0, 3.14 / 2);
	//绘制圆弧
	arc(200, 200, 100, 100, 0, 3.14 / 2);
	getchar();//暂停

	//绘制多边形
	POINT points[] = { {0,100},{100,-100},{-100,-100} };
	POINT points1[4] = { {200,200},{-200,200},{-200,-200},{200,-200} };
	polygon(points, 3);
	polygon(points1, 4);
	//绘制多边形(不封闭的w)
	POINT points2[5] = { {-200,200},{-100,-100},{0,50},{100,-100},{200,200} };
	polyline(points2, 5);
	getchar();//暂停
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值