下载此文档

实验二:C语言图形基础知识.docx


文档分类:IT计算机 | 页数:约12页 举报非法文档有奖
1/12
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/12 下载此文档
文档列表 文档介绍
实验二c语言图形基础知识
一、 实验目的
认识c语言程序中的图形参数和有关图形显示的基础知识;
学习C语言各种图形函数和图形命令及其使用。
学习并运行图形显示例程,掌握C语言图形编程基本常识。
二、 实验设备及软件
计算机系统 ft = getmaxx() / 2-50;
top 二 getmaxy() / 2-50;
right = getmaxx() / 2 + 50;
bottom = getmaxy() / 2 +50;
/* draw a rectangle */
rectangle(left, top, right, bottom);
/* clean up */
getchO ;
closegraph ();
return 0;
运行出来的图形:
修改后的程序一:
^include <graphics. h>
ttinclude <stdlib. h>
^include <stdio. h>
ttinclude <conio. h>
int main(void)
(
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int left, top, right, bottom;
/* initialize graphics and local variables */ initgraph(fegdriver, &gmode, 〃〃);
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf(^Graphics error: %s\n〃, grapherrormsg(errorcode));
printf (z/Press any key to halt:〃);
getchO ;
exit (1); /* terminate with an error code */
}
left = getmaxx() / 2 - 100;
top = getmaxy() / 2 - 100;
right = getmaxx() / 2 + 100;
bottom = getmaxy() / 2 + 100;
setbkcolor (1);
setcolor (7);
/* draw a rectangle */
rectangle(left, top, right, bottom);
/* clean up */
getch();
closegraph ();
return 0;
)
修改后的程序一运行的图形:
修改一:left = getmaxxO / 2 - 50; top = getmaxy () / 2 - 50;right = getmaxx () / 2 + 50;bottom = getmaxy() / 2 + 50;修改参数克改变举行的四个定点的 位置,从而改变大小
修改二:增加setbkcolor (1) ; setcolor (7);改变了图形的颜色和背景颜色
2)没有修改的原程序二: #include <graphics. h>
ttinclude <stdlib. h> ftinclude <stdio. h>
^include <conio. h> int main(void)
(
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int i, maxx, maxy;
/* our polygon array */
int poly[8];
/* initialize graphics, local variables */
initgraph(fegdriver, &gmode, 〃〃);
/* read result of initialization */
errorcode 二 graphresult();
if (errorcode != grOk)
/* an error occurred */
(
printf(^Graphics error: %s\n〃,
grapherrorms g(errorcode));
printf(z/Press any key to halt:");
getchO ;
exit (1);
/* terminate with an error code */

实验二:C语言图形基础知识 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数12
  • 收藏数0 收藏
  • 顶次数0
  • 上传人sssmppp
  • 文件大小53 KB
  • 时间2022-06-27
最近更新