gpt4 book ai didi

c# - 如何使用 svg .net 添加蒙版?

转载 作者:行者123 更新时间:2023-12-05 05:35:03 25 4
gpt4 key购买 nike

我不知道如何像这样使用 svg .net 将掩码添加到一行:

<svg height="210" width="500">
<mask id="myMask">`
<rect x="0" y="0" width="50" height="50" fill="white" />
<rect x="170" y="150" width="50" height="50" fill="white" />
</mask>
<line x1="0" y1="0" x2="200" y2="200" style="stroke:gray;stroke-width:2" stroke-dasharray="5, 5" />
<line x1="0" y1="0" x2="200" y2="200" style="stroke:blue;stroke-width:2" mask="url(#myMask)"/>
</svg>

最佳答案

我是这样做的。剪辑中的区域将是可见部分。

 var rectangle = new SvgPolygon();
var group = new SvgGroup();

var clip2 = new SvgClipPath
{
ID = "Clip2",
Children =
{
new SvgRectangle()
{
X = 0,
Y = 0,
Width = 40,
Height = 40
}
}
};

group.Children.Add(clip2);
group.Children.Add(rectangle);
rectangle.ClipPath = new Uri("url(#Clip2)", UriKind.Relative);
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xml="http://www.w3.org/XML/1998/namespace" width="989" height="162" viewBox="0, 0, 100, 100">
<g stroke-width="1" font-family="Roboto" font-size="8" font="Roboto" fill-opacity="0" groupName="TopChord" style="stroke:black;">
<g>
<clipPath id="Clip2">
<rect x="0" y="0" width="40" height="40" />
</clipPath>
<polygon points="10,20 10,60 90,60 90,20" clip-path="url(#Clip2)" id="0" stroke-width="1" fill-opacity="1" />
</g>
</g>
</svg>

关于c# - 如何使用 svg .net 添加蒙版?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73562513/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com