SVG feGaussianBlur and feColorMatrix filters not working in Chrome?

﹥>﹥吖頭↗ 提交于 2019-12-04 17:25:36

The Color Matrix filter applied reads

<feColorMatrix mode="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 19 -9" />

It is - in theory - mathematically identical to the following Component Transfer filter:

<feComponentTransfer>
  <feFuncA type="linear" slope="19" intercept="-9" />
</feComponentTransfer>

In practice, implementations seem to make a difference. For me, the second version gives the intended result in Chrome 62 (Linux), while the first version is washed-out as described.

Unfortunately both versions do not work with Firefox for Windows and Safari.

Codepen

The filter tries to create a sort of "cutoff" value that says: if opacity is below a theshold value, set it to 0, if it is above, set it to 1. But in fact the is a small intermediate region (0.437 < opacity < 0.526) where the resulting opacity is inbetween.

If you want to work with a truely discrete function, it would be this one:

<feComponentTransfer>
  <feFuncA type="discrete" tableValues="0 1" />
</feComponentTransfer>

Codepen

And this seems to work in Firefox for Windows.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!