首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

SVG - How do I cut a <path> in half?

To cut a <path> in half, you can use the <rect> element and the width and height properties to define the size of the rectangle and then position it over the <path> element. Here's an example:

代码语言:php
复制
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
  <rect x="25" y="25" width="50" height="50" fill="none" stroke="black" stroke-width="1"/>
  <path d="M50,50 Q75,75 100,50 Q125,75 150,50 Q175,75 200,50" fill="none" stroke="black" stroke-width="1"/>
</svg>

In this example, the <rect> element is positioned at (25, 25) and has a width and height of 50x50. It is filled with none, has a black border with a width of 1, and is positioned absolute to allow it to cut into the <path> element. The <path> element is positioned at (50, 50) and has a M command moving the starting point to (50, 50) and a Q command for the first quadratic curve to (75, 75) and a Q command for the second quadratic curve to (100, 50) and a Q command for the third quadratic curve to (125, 75) and a Q command for the fourth quadratic curve to (150, 50) and a Q command for the fifth quadratic curve to (175, 75) and a Q command for the sixth quadratic curve to (200, 50). All of these commands have a fill and stroke property set to none and a stroke-width of 1.

页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

评价打分组件,SVG 半颗星的解决方案!

svg" viewBox="0 0 32 32"> aria-label属性用来给当前元素加上的标签描述,接受字符串作为参数。...如何重用SVG 我们可以把上面的SVG 标签复制五次,或者提取path数据并保存在某个地方,然后在不重复代码的情况下重新使用它。我们选择后者。...-- Content --> 在该SVG中,我们需要在元素中包含path数据。根据MDN: symbol 元素用于定义图形模板对象,可以通过元素来实例化。.../svg" viewBox="0 0 32 32" id="star"> 有了这个设置,我们现在可以用...结合在一起时,我们可以创建一个cut-out effect效果。 注意,白色矩形被定位在0,0点,而黑色矩形被定位在50%,0。下面是它的效果: 涂写的部分代表最终结果,半颗星。

66010
领券