在Turbo C图形中,我们使用 图样H 用于绘制不同形状(如圆形、矩形等),以不同格式(不同字体和颜色)显示文本(任何消息)。通过使用图形。我们可以制作节目、动画和游戏。这些对初学者很有用。
null
使用的功能:
- 延迟(n): 来自dos的函数。h头文件负责根据给定值n将程序保存一段时间。
- setcolor(n): 来自图形的函数。设置指针(光标)颜色的h头文件。
- 弧(x,y,a1,a2,r): 来自图形的函数。h头文件,以(x,y)为中心(a2-a1)为角度,r为半径绘制圆弧。
实施:
// A C program to make a rainbow. This program would only // work in Turbo C compiler in DOS compatible machine #include<stdio.h> #include<graphics.h> #include<dos.h> // function for making of rainbow void rainbow() { // auto detection int gdriver = DETECT,gmode; int x, y, i; // initialize graphics mode(passed three arguments to // initgraph function) // &gdriver is the address of gdriver variable, &gmode is // the address of gmode and // "C:\Turboc3\BGI" is the directory path where BGI files are stored initgraph(&gdriver,&gmode, "C:\Turboc3\BGI" ); x = getmaxx() / 2; //finding centre x-ordinate of screen y = getmaxy() / 2; //finding centre y-ordinate of screen for (i=30; i<200; i++) { // delay function under dos.h for holding the // function for some time delay(100); // selecting color for making of rainbow setcolor(i/10); // making of arc with fixed centre and increasing radius arc(x, y, 0, 180, i-10); } } // driver program int main() { rainbow(); return 0; } |
参考: http://www.xcnotes.com/graphics-in-c-language/draw-rainbow-in-c
本文由 希瓦姆·普拉丹(anuj_charm) .如果你喜欢GeekSforgek,并想贡献自己的力量,你也可以使用 贡献极客。组织 或者把你的文章寄到contribute@geeksforgeeks.org.看到你的文章出现在Geeksforgeks主页上,并帮助其他极客。
如果您发现任何不正确的地方,或者您想分享有关上述主题的更多信息,请写下评论。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END