svg - SVG feImage 过滤器剪辑中风 - 如何阻止它?
问题描述
我正在尝试仅为SVG 中的路径笔划创建一个过滤器,但feImage
不断被剪裁到我认为是边界框(请参见下面的代码中的绿色矩形作为边界框)。我尝试将filter
'sx/y 和 width/height 设置为各种位置/尺寸,这似乎是普遍的建议,但没有任何效果。x/y 只是偏移feImage
大于 100% 的宽度/高度没有影响。
我不会提前知道描边或填充是实心还是其他东西(比如linearGradient
.
下面演示了我想要做什么 - 只需获取形状的笔触(无论大小或填充)并为所有现代浏览器应用过滤器。
注意:FF 甚至不显示左手feImage
. Chrome 剪辑左侧和顶部。边缘夹住所有 4 个侧面。
<html>
<body>
<svg width="960" height="540" >
<rect width="960" height="540" stroke="#385D8A" fill="white" stroke-width="3"/>
<svg name="BoundingBox1" class="rect" x="100" y="100" overflow="visible" fill="none" stroke="#00ff00" stroke-width="1">
<path d="M0,0L121.68,0L121.68,121.68L0,121.68Z" />
</svg>
<!-- BELOW IS MODIFIED "SPEECH" SHAPE. NEED A FILTER ON THE STROKE ONLY. -->
<svg name="Speech-strokeonly" x="100" y="100" overflow="visible" fill="blue" stroke="orange" stroke-width="12" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<path d="M35.541,137.084L30.985,113.988A60.926,60.926 0 1 1 53.043,121.34Z" id="strokeOnly" fill="none"/>
<filter id="effs0sp9" color-interpolation-filters="sRGB" x="0" y="0">
<feImage xlink:href="#strokeOnly" />
</filter>
</defs>
<path d="M35.541,137.084L30.985,113.988A60.926,60.926 0 1 1 53.043,121.34Z" id="effs0sp9" filter="url(#effs0sp9)" overflow="visible" />
<text y="160" stroke="black" stroke-width="0.2">this is the one that has undesirable clipping of</text>
<text y="178" stroke="black" stroke-width="0.2">of stroke in Chrome/Edge. Doesn't appear at all in FF</text>
</svg>
<!-- BELOW IS ORIGINAL WITH BOTH FILL AND STROKE -->
<svg name="BoundingBox2" x="400" y="100" overflow="visible" fill="none" stroke="green" stroke-width="1">
<path d="M0,0L121.68,0L121.68,121.68L0,121.68Z" />
</svg>
<svg name="Speech-original" x="400" y="100" overflow="visible" fill="blue" stroke="orange" stroke-width="12">
<path d="M35.541,137.084L30.985,113.988A60.926,60.926 0 1 1 53.043,121.34Z" id="effs0sp9" />
<text y="-22" stroke="black" stroke-width="0.2">this is the original one</text>
<text y="-6" stroke="black" stroke-width="0.2">that I just want the stroke as feImage from</text>
</svg>
</svg>
</body>
</html>
有没有办法只抓取一个形状的整个笔画并在过滤器中使用?
解决方案
推荐阅读
- javascript - 我可以使用 Javascript 将多个音频文件混合成一个音频吗?
- c++ - Qt:使用visual studio开发时在哪里可以找到.pro文件
- python - 如何从项目目录中的文件导入?
- python-3.x - WinError 5:为 Python 安装 pip numba 和 librosa 时拒绝访问
- python - 为什么方法解析顺序会影响我的代码的行为?
- python - 使用 Panda,根据 ID 列表和新值更新列值
- c# - 使用 Process.Start 在 C# 中传递 powershell 多个参数
- java - 将代码python转换为Java,找到达到1的最小步骤数
- azure - 复制文件任务未复制到 Azure 存储库
- ajax - ajax get方法一数据为null怎么处理