[英]Why is my svg mask partially transparent?
I have the following svg code:我有以下 svg 代码:
<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<defs>
<mask id="mask" x="0" y="0" width="100" height="100">
<rect x="0" y="0" width="100" height="100" fill="rgb(20, 182, 197)" fill-opacity="100%"></rect>
<circle cx="50" cy="50" r="37.5"></circle>
</mask>
</defs>
<rect x="0" y="0" width="100" height="100" mask="url(#mask)" fill="rgb(20, 182, 197)" ></rect>
</svg>
It basically creates a rectangle with a cutout circle, but the part with the non cutout part is partially transparent.它基本上创建了一个带有切口圆的矩形,但带有非切口部分的部分是部分透明的。
How do i fix this?我该如何解决?
With masks, the transparency is determined by the brightness.使用蒙版,透明度由亮度决定。 You are setting the rectangle's color to rgb(20, 182, 197)
, which has a 43% luminescence value, so you get 43% transparency.您将矩形的颜色设置为rgb(20, 182, 197)
,它的发光值为 43%,因此透明度为 43%。 If you need the outer rectangle to be opaque, then you have to set its color to have 100% brightness (ie white).如果您需要外部矩形不透明,则必须将其颜色设置为 100% 亮度(即白色)。
So, change所以,改变
<rect x="0" y="0" width="100" height="100" fill="rgb(20, 182, 197)" fill-opacity="100%">
to至
<rect x="0" y="0" width="100" height="100" fill="white">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.