mask-type
mask-type
属性指示在遮罩时,要为 <mask>
元素的内容使用哪种遮罩模式,是 alpha(透明度)还是 luminance(亮度)。
你可以将此属性与以下 SVG 元素一起使用
注意: 此演示属性有一个对应的 CSS 属性:mask-type
。当同时指定两者时,CSS 属性具有优先权。
示例
html
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<!-- Two identical masks other than the id and mask-type values -->
<mask id="myMask1" mask-type="alpha">
<rect
fill="rgb(10% 10% 10% / 0.4)"
x="0"
y="0"
width="100%"
height="100%" />
<circle fill="rgb(90% 90% 90% / 0.6)" cx="50" cy="50" r="35" />
</mask>
<mask id="myMask2" mask-type="luminance">
<rect
fill="rgb(10% 10% 10% / 0.4)"
x="0"
y="0"
width="100%"
height="100%" />
<circle fill="rgb(90% 90% 90% / 0.6)" cx="50" cy="50" r="35" />
</mask>
<!-- The first rect is masked with an alpha mask -->
<rect x="0" y="0" width="45" height="45" mask="url(#myMask1)" fill="red" />
<!-- The last rect is masked with a luminance mask -->
<rect x="55" y="0" width="45" height="45" mask="url(#myMask2)" fill="red" />
</svg>
mask
对于 <mask>
,mask-type
定义了遮罩元素的内容是作为亮度遮罩还是透明度遮罩进行处理。
值 | alpha | luminance |
---|---|
默认值 | luminance |
可动画的 | alpha |
规范
此特性似乎未在任何规范中定义。浏览器兼容性
加载中…