javascript - 过滤 SVG 适用于 Canvas 不适用于 Chrome

标签 javascript css svg filter html5-canvas

我有 chrome 版本:33.0.1750.117

在此版本之前,应用于我的 Canvas 的滤镜 SVG 可以工作,但现在它可以在 firefox 上工作,但不能在 chrome 上工作

你可以用这个例子来测试

example grayscale filter on canvas

<svg xmlns="http://www.w3.org/2000/svg">
 <filter id="grayscale" color-interpolation-filters="sRGB">
  <feColorMatrix type="matrix"  
     values="0.3333 0.3333 0.3333 0 0.001 
             0.3333 0.3333 0.3333 0 0.001  
             0.3333 0.3333 0.3333 0 0.001  
             0 0 0 1 0.001"/>

</svg>
<canvas id="myCanvas" width="300" height="300"></canvas>

CSS:

#myCanvas:hover {
        filter: url(#grayscale); /* Firefox */      
        -ms-filter: url(#grayscale); /* IE */
        -webkit-filter: url(#grayscale); /* Webkit */
        }

最佳答案

你也可以使用-webkit-filter: grayscale(100%);

参见 grayscale in chrome via css .

关于javascript - 过滤 SVG 适用于 Canvas 不适用于 Chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22052993/

相关文章:

javascript - 如何获取先前创建的 Google Chart 的实例?

javascript - Multi-drm 内容的 Dash.js 问题

javascript - 尝试使用 map v3 和 jquery 复制谷歌地图滑动面板

html - CSS 位置固定

jquery - 我如何使用 jquery 在窗口调整大小时缩放 Raphael js 元素

javascript - 如何使用下面的示例将文本添加到 D3 中的 SVG 元素

javascript - anchor 上的 svg 动画

javascript - 如何修改 javascript 调用的 mailto 链接以在 Chrome 中工作

javascript - 如何从谷歌地图中删除缩放、地形和用户导航?

php - 我如何根据 while 循环中 3 的差异计数给 div 背景颜色