这里需要安装QT,之前的篇章中有介绍,专门用于C++的图形库。
下载斯坦福的库地址
https://pan.baidu.com/s/1qYS6Pqs
库主要包含一个empty-project.pro就是文件的目录结构,qt的专用格式,相当于目录树的形式。
包含各个子类文件夹
collections 容器类的库
graphics 图形相关的库
io 输入输出相关的库
private 私有库
system 系统相关的库,主要是错误处理方面
util 常用的工具库
写一个图形库验证这些库的有效性
// This program illustrates the use of graphics using the GWindow class.
#include "gwindow.h"
void drawDiamond(GWindow &gw);
void drawRectangleAndOval(GWindow &gw);
int main() {
GWindow gw;
drawDiamond(gw);
drawRectangleAndOval(gw);
return 0;
}
void drawDiamond(GWindow &gw) {
double width = gw.getWidth();
double height = gw.getHeight();
gw.drawLine(0, height/2, width/2, 0);
gw.drawLine(width/2, 0, width, height/2);
gw.drawLine(width,height/2, width/2, h