河南企业网站排名优化,室内设计师找图片的网站,增城营销网站建设,芜湖做网站哪家好先说一下tinyXML库的配置#xff1a;
很简单#xff0c;去下面官网下载
TinyXML download | SourceForge.net
解压后是这样 直接将红框中的几个文件放到项目中即可使用
关于svg文件#xff0c;SVG是基于XML的可扩展矢量图形#xff0c;svg是xml文件#xff0c;但是xml…先说一下tinyXML库的配置
很简单去下面官网下载
TinyXML download | SourceForge.net
解压后是这样 直接将红框中的几个文件放到项目中即可使用
关于svg文件SVG是基于XML的可扩展矢量图形svg是xml文件但是xml范围更广不一定是svg
使用tinyxml库就是按照svg的格式将内容写为xml文件其实也可以写为svg格式直接打开就是图像。 将xml后缀改为svg打开看看图片 例子
#include tinyxml.h
#includeiostream
#includestringint main() {// 创建 XML 文档对象TiXmlDocument doc;// 添加根元素TiXmlElement* root new TiXmlElement(svg);root-SetAttribute(version, 1.1);root-SetAttribute(xmlns, http://www.w3.org/2000/svg);root-SetAttribute(width, 400);root-SetAttribute(height, 300);doc.LinkEndChild(root);// 绘制棋盘格int cellWidth 100;int cellHeight 100;for (int row 0; row 3; row) {for (int col 0; col 4; col) {TiXmlElement* rect new TiXmlElement(rect);rect-SetAttribute(x, std::to_string(col * cellWidth).c_str());rect-SetAttribute(y, std::to_string(row * cellHeight).c_str());rect-SetAttribute(width, std::to_string(cellWidth).c_str());rect-SetAttribute(height, std::to_string(cellHeight).c_str());if ((row col) % 2 0) {rect-SetAttribute(fill, white);}else {rect-SetAttribute(fill, black);}root-LinkEndChild(rect);}}// 保存为 SVG 文件或xml文件doc.SaveFile(chessboard.xml);return 0;
}