【发布时间】:2012-09-30 14:28:59
【问题描述】:
我在将<mask> 层应用到<g> 路径组时遇到问题。
当我将<mask> 应用到<rect> 时,它按预期工作,但在<g> 上使用它时,整个组都消失了。
这是我的文件
<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="600px" height="600px" viewBox="0 0 600.000000 600.000000" preserveAspectRatio="xMidYMid meet">
<defs>
<mask id="myMask" maskUnits="userSpaceOnUse" x="0" y="0" width="600" height="600">
<rect fill="white" x="0" y="0" width="600" height="600"></rect>
<circle cx="30" cy="30" r="20" fill="black"></circle>
<circle cx="300" cy="300" r="200" fill="black"></circle>
</mask>
</defs>
<rect fill="#FFFFFF" width="21456" height="21456" mask="url(#myMask)"></rect>
<g transform="translate(0.000000,600.000000) scale(0.100000,-0.100000)" fill="#100059" stroke="none" mask="url(#myMask)"> <!-- a bunch of <path>s --> </g>
<g transform="translate(0.000000,600.000000) scale(0.100000,-0.100000)" fill="#f542b3" stroke="none"> <!-- a bunch of <path>s --> </g>
</svg>
我还尝试了使用剪辑路径的类似方法,结果相同 - 使用 <rect> 而不是 <g>。我还尝试将mask 属性应用于单个<path> 元素,结果相同
任何帮助表示赞赏
【问题讨论】: