- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我使用 SourceAlpha
作为阴影在 SVG 中创建了一个投影,因此它是纯黑色的。使用 feColorMatrix
我稍微降低了不透明度,但它看起来仍然不是我想要的 - 我希望阴影的颜色与特定颜色值相匹配。所以我更深入地研究了 feColorMatrix
。
现在我不使用 SourceAlpha
作为阴影的来源,而是使用 SourceGraphic
。由于我的矢量图像是纯白色的 rgba(255, 255, 255, 1)
,我可以这样计算阴影的颜色:
<feColorMatrix in="the-shadow" result="color-out" type="matrix"
values="0.0157 0 0 0 0
0 0.3059 0 0 0
0 0 0.7765 0 0
0 0 0 1 0 "/>
结果应该是一个深蓝色阴影,也就是 rgba(4, 78, 198, 1)
。
实际上这是有效的,我相信计算都是正确的,但是当使用相同颜色的 CSS3 创建阴影时,有一个明显的区别:SVG 过滤器似乎渲染颜色有点太亮。有什么办法可以解决这个问题吗?
最佳答案
feColorMatrix 与大多数滤镜一样在 linearRGB 颜色空间中运行。如果你想要 sRGB 颜色,尝试设置 color-interpolation-filters ="sRGB"作为 feColorMatrix 的一个属性。
<svg width="100%" xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 640 480" height="100%"
xmlns="http://www.w3.org/2000/svg">
<filter id="cm">
<feColorMatrix in="SourceGraphic" type="matrix"
values="0.0157 0 0 0 0
0 0.3059 0 0 0
0 0 0.7765 0 0
0 0 0 1 0 "/>
</filter>
<filter id="cmRGB">
<feColorMatrix color-interpolation-filters="sRGB" in="SourceGraphic" type="matrix"
values="0.0157 0 0 0 0
0 0.3059 0 0 0
0 0 0.7765 0 0
0 0 0 1 0 "/>
</filter>
<rect width="100%" height="50%" fill="white" filter="url(#cm)"/>
<rect y="50%" width="100%" height="100%" fill="white" filter="url(#cmRGB)"/>
</svg>
我在 Firefox 上看起来确实不一样。
关于css - 使用 feColorMatrix 匹配 SVG 中的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14663252/
我有一个灰度图像。我想将其过滤为 white -> color1 和 black -> color2。两种颜色都采用十六进制 CSS 语法。我需要做哪些数学运算才能获得这种效果? 我正在使用这种语法:
我有一个灰度图像。我想将其过滤为 white -> color1 和 black -> color2。两种颜色都采用十六进制 CSS 语法。我需要做哪些数学运算才能获得这种效果? 我正在使用这种语法:
我有一个相当简单的设置,我想通过使用 svg 过滤器来改变 svg 图像的颜色: Please see the attached codepen for details .
我对 SVG 几乎一无所知,但我的网站上运行了一个脚本,它通过应用 svg 滤色器然后在悬停时将其移除来在彩色和黑白之间切换图像。颜色的色调似乎是使用下面显示的值矩阵设置的... 我的问题是我想更
我使用 SourceAlpha 作为阴影在 SVG 中创建了一个投影,因此它是纯黑色的。使用 feColorMatrix 我稍微降低了不透明度,但它看起来仍然不是我想要的 - 我希望阴影的颜色与特定颜
我在 codepen 的演示中看到了这段代码。
我正在根据用户的日期和时间异步加载 SVG 过滤器。它在 Chrome 上运行良好,但在 Safari/Firefox 上运行不佳。 简化示例 1。 HTML:通过单击按钮,我们会将 svg 字符串加
我是一名优秀的程序员,十分优秀!