[英]Drawing an arc in C++ Graphics.h
I'm using graphics.h in order to start with a bit of graphic in C++, but when I run the code the program crash.我使用 graphics.h 是为了从 C++ 中的一些图形开始,但是当我运行代码时,程序崩溃了。 I'm using CodeBlocks as a compiler and Windows 8.1 as an operating system.
我使用 CodeBlocks 作为编译器,使用 Windows 8.1 作为操作系统。 What should I do in order to make it works?
我应该怎么做才能使其正常工作? Here is the code:
这是代码:
#include <graphics.h>
int main()
{
int gd = DETECT;
int gm;
initgraph(&gd, &gm, "C:\\TC\\BGI");
arc(200, 200, 0, 130, 50);
getch();
closegraph();
}
"What should I do to make it works?" “我该怎么做才能让它发挥作用?”
1) Forget about graphics.h it is obsolete. 1) 忘记 graphics.h 它已经过时了。
2) Get yourself a modern compiler (for example; Clang 7.1, GCC 8.3 or Visual Studio 2017). 2) 为自己准备一个现代编译器(例如;Clang 7.1、GCC 8.3 或 Visual Studio 2017)。
3) Pick a modern graphics library. 3)选择一个现代图形库。 SFML and SDL are popular options.
SFML和SDL是流行的选项。
An alternative to BGI's graphics.h
is TX Library. BGI 的
graphics.h
的替代品是 TX 库。 See here: https://sourceforge.net/projects/txlib .请参见此处: https : //sourceforge.net/projects/txlib 。 The docs are here: http://storage.ded32.net.ru/Lib/TX/TXUpdate/Doc/HTML.ru ).
文档在这里: http : //storage.ded32.net.ru/Lib/TX/TXUpdate/Doc/HTML.ru )。 The docs are currently in Russian.
文档目前为俄语。
A simple example:一个简单的例子:
#include "TXLib.h"
int main()
{
txCreateWindow (800, 600);
txLine (320, 290, 320, 220);
txLine (320, 290, 280, 350);
txLine (320, 290, 360, 350);
txLine (320, 230, 270, 275);
txLine (320, 230, 400, 220);
txCircle (320, 190, 30);
txSelectFont ("Times New Roman", 60);
txTextOut (240, 400, "Hello, world!");
txArc (100, 100, 300, 200, 45, 270);
return 0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.