【问题标题】:SVG Filter: Different colouring depending on browserSVG过滤器:不同的颜色取决于浏览器
【发布时间】:2019-09-25 13:15:36
【问题描述】:

我有一张黑白图像,我正在尝试使用 SVG 滤镜重新着色。 Safari 中的颜色看起来比 Chrome 中的颜色要深得多,有什么办法可以让 Safari 看起来与 Chrome 更一致?

CSS代码如下

.container-teamMembers a.six img {
    -webkit-filter: url(#duotone_bright_green);
    -moz-filter: url(#duotone_bright_green);
    -o-filter: url(#duotone_bright_green);
    -ms-filter: url(#duotone_bright_green);
    filter: url(#duotone_bright_green);
}

SVG 过滤器是

<svg xmlns="http://www.w3.org/2000/svg" class="svg-filters">
<filter id="duotone_bright_green">
    <feColorMatrix type="matrix" result="grayscale" values="1 0 0 0 0
              1 0 0 0 0
              1 0 0 0 0
              0 0 0 1 0"></feColorMatrix>
<feComponentTransfer color-interpolation-filters="sRGB" result="duotone_blue_black">
<feFuncR type="table" tableValues="0.03137254902 0.74509803921"></feFuncR>
<feFuncG type="table" tableValues="0.007843137255 0.81568627451"></feFuncG>
<feFuncB type="table" tableValues="0.02352941176 0.0431372549"></feFuncB>
<feFuncA type="table" tableValues="0 1"></feFuncA>
</feComponentTransfer> 
</filter>
</svg>

谁能告诉我如何让 Safari 看起来更轻巧/与 Chrome 更一致?

【问题讨论】:

    标签: svg svg-filters


    【解决方案1】:

    这看起来很愚蠢 - 但将 color-interpolation-filters="sRGB" 移动到过滤器元素而不是 feComponentTransfer 中 - Safari 在将其放入原语时似乎不会检查它。

    这是适合我的过滤器。我在旧版 Macbook Pro(2016 年)上的 MacOS Mojave 上运行 Chrome 73 和 Safari 12.1。

    <svg xmlns="http://www.w3.org/2000/svg" class="svg-filters">
    <filter id="duotone_bright_green" color-interpolation-filters="sRGB">
        <feColorMatrix type="matrix" result="grayscale" values="1 0 0 0 0
                  1 0 0 0 0
                  1 0 0 0 0
                  0 0 0 1 0"></feColorMatrix>
    <feComponentTransfer  result="duotone_blue_black">
    <feFuncR type="table" tableValues="0.03137254902 0.74509803921"></feFuncR>
    <feFuncG type="table" tableValues="0.007843137255 0.81568627451"></feFuncG>
    <feFuncB type="table" tableValues="0.02352941176 0.0431372549"></feFuncB>
    <feFuncA type="table" tableValues="0 1"></feFuncA>
    </feComponentTransfer> 
    </filter>
    </svg>
    

    这是屏幕截图 - 左侧是 Chrome,右侧是 Safari。

    【讨论】:

    • 这是作为 webkit 错误报告的吗?
    • 遗憾的是,Safari 中的图像仍然会变暗:(
    • 在 Safari/MacOS 上为我工作 - 让我再检查一次。
    • 我能检查一下你的意思是不是这样......
    • 检查了它,是的,它确实适用于我的 Mac/Chrome/Safari。我添加了我正在使用的过滤器文本和两个 codepen 并排的屏幕截图。
    猜你喜欢
    • 1970-01-01
    • 2015-01-02
    • 1970-01-01
    • 2018-11-12
    • 2015-08-04
    • 1970-01-01
    • 2014-12-22
    • 2015-01-25
    • 1970-01-01
    相关资源
    最近更新 更多