Javascript HTML5画布上下文globalAlpha无法处理图像[iOS]

Javascript HTML5画布上下文globalAlpha无法处理图像[iOS],javascript,ios,canvas,html5-canvas,Javascript,Ios,Canvas,Html5 Canvas,我正在更新“this.opacity”值以使svg徽标褪色。以下代码在iOS(8)上除外 iOS不支持为SVG图像的alpha设置动画。但我找到了解决办法。如果使用以下代码创建全屏画布以进行缩放: var ratio = window.devicePixelRatio || 1, width = $(window).width(), height = $(window).height(); this.canvas.width = width * ratio; this.canv

我正在更新“this.opacity”值以使svg徽标褪色。以下代码在iOS(8)上除外


iOS不支持为SVG图像的alpha设置动画。但我找到了解决办法。如果使用以下代码创建全屏画布以进行缩放:

var ratio = window.devicePixelRatio || 1,
    width = $(window).width(),
    height = $(window).height();

this.canvas.width = width * ratio;
this.canvas.height = height * ratio;
this.canvas.style.width = width + "px";
this.canvas.style.height = height + "px";

this.update();
您将能够使用两倍大小的图像来提供视网膜支持,这样您就不必在画布中使用SVG元素(这对您的记忆也非常糟糕)。好的是,图像可以接受设置上下文的全局alpha


希望读者了解更多:-)。

“网络工作”是什么意思?Alpha is==1.0??你知道
globalAlpha
需要一个介于0和1之间的数字吗?我将其设置为动画。不透明度介于0和1之间,但我刚刚发现iOS设备不接受SVG图像上的Alpha。@jvakuiler首先将SVG绘制到一个临时画布,如果是这样的话,然后将该画布用作图像源。
var ratio = window.devicePixelRatio || 1,
    width = $(window).width(),
    height = $(window).height();

this.canvas.width = width * ratio;
this.canvas.height = height * ratio;
this.canvas.style.width = width + "px";
this.canvas.style.height = height + "px";

this.update();