- 创建一个winfrom
- 引用 NuGet CefSharp.WinForms
- 引用 NuGet SVG Rendering Library 可能出来 Svg.Custom
- 创建代码
public Form1(){
InitializeComponent();
InitUI();}
private void InitUI() {
ChromiumWebBrowser webview = new ChromiumWebBrowser("");
webview.LoadUrl("D:\\练习\\Source\\WfSvg_test\\WfSvg_test\\svg1.html");
webview.Dock = DockStyle.Fill;
this.Controls.Add(webview);
}
- 创建一个svg1.html
<!DOCTYPE html>
<html>
<body>
<h1>My first SVG</h1>
<svg align="center" width="300" height="500" xmlns="http://www.w3.org/2000/svg" version="1.1">
<circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill="red" />
<circle cx="200" cy="150" r="40" stroke="black" stroke-width="3" fill="blue" />
<rect x="160" y="160" height="100" width="100"
style="stroke:#ff0000; fill: #0000ff">
<animateTransform attributeName="transform"
begin="0s"
dur="3s"
type="rotate"
from="0 210 210"
to="360 210 210"
repeatCount="indefinite" />
</rect>
<circle cx="0" cy="50" r="15" fill="blue" stroke="black" stroke-width="1">
<animate attributeName="cx"
from="0"
to="100"
dur="5s"
repeatCount="indefinite" />
</circle>
</svg>
</body>
</html>
6.最后运行,查看效果图