ImageVerifierCode 换一换
格式:DOCX , 页数:12 ,大小:54.43KB ,
资源ID:19848966      下载积分:12 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/19848966.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(实验二C语言图形基础知识Word文档格式.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

实验二C语言图形基础知识Word文档格式.docx

1、2) void far line(int x0, int y0, int x1, int y1);画一条从点(x0, y0)到(x1, y1)的直线。3) void far lineto(int x, int y);画一作从现行游标到点(x, y)的直线。4) void far linerel(int dx, int dy);画一条从现行游标(x, y)到按相对增量确定的点(x+dx, y+dy)的直线。5) void far circle(int x, int y, int radius);以(x, y)为圆心, radius为半径, 画一个圆。6) void far arc(int x,

2、int y, int stangle, int endangle, int radius);以(x, y)为圆心, radius为半径, 从stangle开始到endangle结束(用度表示)画一段圆弧线。7) void ellipse(int x, int y, int stangle, int endangle, int xradius,int yradius);以(x, y)为中心, xradius, yradius为x轴和y轴半径, 从角stangle开始到endangle结束画一段椭圆线, 当stangle=0, endangle=360时, 画出一个完整的椭圆。8) void fa

3、r rectangle(int x1, int y1, int x2, inty2);以(x1, y1)为左上角, (x2, y2)为右下角画一个矩形框。9) void far drawpoly(int numpoints, int far *polypoints);画一个顶点数为numpoints, 各顶点坐标由polypoints 给出的多边形。图形函数的基本表示、 含义以及基本应用。如:1) voidfarclearviewport(void);清除现行图形窗口的内容。2) voidouttextchar*textstring该函数输出字符串指针textstring所指的文本在现行位置。

4、3. 初步认识C语言图形函数的编程与运行; 在 C 语言环境下, 运行图形程序示例,观察显示结果,分析程序结构和含义,学习C语言图形函数的编程应用;4. 修改相关程序内容,观察运行结果,总结经验和结论分析。1) 没有修改的原程序一:#include stdlib.hstdio.hconio.hint main(void) /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int left, top, right, bottom; /* initialize graphics and local variab

5、les */ initgraph(&gdriver, &gmode, /* read result of initialization */ errorcode = graphresult(); if (errorcode != grOk) /* an error occurred */ printf(Graphics error: %sn, grapherrormsg(errorcode);Press any key to halt: getch(); exit(1); /* terminate with an error code */ left = getmaxx() / 2 - 50;

6、 top = getmaxy() / 2 - 50; right = getmaxx() / 2 + 50; bottom = getmaxy() / 2 + 50; /* draw a rectangle */ rectangle(left,top,right,bottom); /* clean up */ closegraph(); return 0;运行出来的图形:修改后的程序一: left = getmaxx() / 2 - 100; top = getmaxy() / 2 - 100; right = getmaxx() / 2 + 100; bottom = getmaxy() /

7、 2 + 100; setbkcolor(1); setcolor(7);修改后的程序一运行的图形:修改一:left = getmaxx() / 2 - 50;top = getmaxy() / 2 - 50;right = getmaxx() / 2 + 50;bottom = getmaxy() / 2 + 50;修改参数克改变举行的四个定点的位置,从而改变大小修改二:增加setbkcolor(1);setcolor(7);改变了图形的颜色和背景颜色2) 没有修改的原程序二: int i, maxx, maxy; /* our polygon array */ int poly8; /*

8、initialize graphics, local variables */= grOk) /* an error occurred */, grapherrormsg(errorcode); maxx = getmaxx(); maxy = getmaxy(); poly0 = 20; /* 1st vertext */ poly1 = maxy / 2; poly2 = maxx - 20; /* 2nd */ poly3 = 20; poly4 = maxx - 50; /* 3rd */ poly5 = maxy - 20; /* 4th vertex. fillpoly autom

9、atically closes the polygon. */ poly6 = maxx / 2; poly7 = maxy / 2; /* loop through the fill patterns */ for (i=EMPTY_FILL; iUSER_FILL; i+) /* set fill pattern */ setfillstyle(i, getmaxcolor(); /* draw a filled polygon */ fillpoly(4, poly);未修改的程序运行的图:修改后的程序二: int maxx, maxy; int poly10; /* initializ

10、e graphics and localvariables */, /* termina te with an error code */ setbkcolor(5); setcolor(11); poly0 = 10; poly2 = maxx - 10; poly3 = 10; poly4 = maxx - 30; poly5 = maxy - 10; /* 4th */* drawpoly doesnt automatically close the polygon, so we close it.*/ poly8 = poly0; poly9 = poly1; /* draw the

11、polygon */ drawpoly(5, poly);修改后的程序二运行的图:int poly8;修改成 int poly10;修改了图形的作图颜色增加了setbkcolor(5):修改了图形的背景颜色修改三: poly1 = maxy / 2:poly4 = maxx - 50;修改成:poly0 = 10;poly2 = maxx - 10;poly4 = maxx - 30;改变了图形的坐标位置,从而改变了图形的形状。3) 没有修改的原程序三: int midx, midy; int stangle = 0, endangle = 360; int xradius = 100, yr

12、adius = 50; midx = getmaxx() / 2; midy = getmaxy() / 2; setcolor(getmaxcolor(); /* draw ellipse */ ellipse(midx, midy, stangle, endangle, xradius, yradius);没有修改的原程序三运行的图:修改后的程序三: int xradius = 100, yradius =150; midy = getmaxy() / 3; setcolor(14);修改后的程序三运行的图:yradius = 50;yradius =150;改变了椭圆的高midy = g

13、etmaxy() / 2;midy = getmaxy() / 3;改变了顶点的位置增加setcolor(14);setbkcolor(5);设置了背景颜色和图形颜色四、上机实验报告根据实验内容,在计算机上操作和观察、学习,并围绕上述内容写出实验结论及观察报告,写出相应的运行程序实例和运行结果,以及修改内容和相应运行结果的变化,分析其结论原因。(不少于3个有代表性程序及运行、修改的结论)。实验结论:通过一些画点函数、画线函数、更换背景色、作图色函数,通过用之前学习的C语言,将各种函数连接起来,完成自己想要的图形,自己想要的颜色,通过更改一个数值,能让其变得“面目全非”,通过此次的编程实验能然自己的C语言图形编程能力有了明显的提高,也让自己对C语言和图形相结合有了相当的经验。

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1