文章分享

開放、平等、協(xié)作、快速、分享

當(dāng)前位置:首頁>文章分享

SVG

摘錄:HCTech 無錫和控電子   時(shí)間:2024-04-11   訪問量:1913

SVG 意為可縮放矢量圖形(Scalable Vector Graphics)。

SVG 使用 XML 格式定義圖像。

SVG可直接嵌入到HTML5中

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="190">
  <polygon points="100,10 40,180 190,60 10,60 160,180"
  style="fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;"></svg>


<svg width="100%" height="100%" version="1.1"
xmlns="http://www.w3.org/2000/svg">
<circle cx="100" cy="50" r="40" stroke="black"
stroke-width="2" fill="red"/>
</svg>

Projects that uses wxSVG

wxSVG (sourceforge.io)

Using of wxSVG

Loading and Displaying of SVG

There are two methods to display SVG:


Dynamic creating of SVG

Here is an example of dynamic creation

wxSVGDocument* svgDoc = new wxSVGDocument;
double w=450,h=450;
wxSVGSVGElement* svgElement = new wxSVGSVGElement;
svgElement->SetWidth(w);
svgElement->SetHeight(h);
svgDoc->AppendChild(svgElement);

wxSVGRectElement* rect = new wxSVGRectElement;
rect->SetX(0);
rect->SetY(0);
rect->SetWidth(w);
rect->SetHeight(h);
rect->SetFill(wxSVGPaint(0,0,0));
svgElement->AppendChild(rect);

rect = new wxSVGRectElement;
rect->SetX(50);
rect->SetY(50);
rect->SetWidth(w-100);
rect->SetHeight(h-100);
rect->SetFill(wxSVGPaint(0,0,255));
rect->SetStroke(wxSVGPaint(255,255,255));
rect->SetStrokeWidth(2);
rect->SetFillOpacity(.5);
svgElement->AppendChild(rect);

rect = (wxSVGRectElement*) rect->CloneNode();
double x = w/4+50;
double y = h/4+50;
rect->SetX(x);
rect->SetY(y);
rect->SetWidth(w/2);
rect->SetHeight(h/2);
rect->SetFill(wxSVGPaint(0,0,0));
rect->Rotate(45, x + w/4, y + h/4);
svgElement->AppendChild(rect);

m_svgCtrl->SetSVG(svgDoc);


上一篇:Emscripten 是一個(gè) 開源的編譯器

下一篇:插片規(guī)格?110、187、250的區(qū)別?

在線咨詢

點(diǎn)擊這里給我發(fā)消息 售前咨詢專員

點(diǎn)擊這里給我發(fā)消息 售后服務(wù)專員

在線咨詢

免費(fèi)通話

24小時(shí)免費(fèi)咨詢

請輸入您的聯(lián)系電話,座機(jī)請加區(qū)號

免費(fèi)通話

微信掃一掃

微信聯(lián)系
返回頂部