我有这个问题的小提琴,我试图为每个路径实现一个普通的掩码,以便用Snap制作动画,问题是当我应用掩码时,图像成为B& W并减少它的不透明度。
https://jsfiddle.net/adrianperez/agevu82g/1/
我已经在snap.js谷歌小组询问了,但目前没有答案,任何线索都表明我做错了什么?
var s = new Snap('.brushes'),
allPaths = s.selectAll("path");
allPaths.forEach(function(el) {
el.attr({
fillOpacity: 0
});
});
for(i = 0; i < allPaths.length; i++){
var thisPath = allPaths[i],
img = s.image('http://cf067b.medialib.glogster.com/media/60/607ef3f3255bd2db1e2444562b7468b595e287b42a1ea594ec8a98d30f7ce9f5/cute-kitten.jpg', 0, 0, 454, 322);
img.attr({
fill: 'white'
});
thisPath.attr({
mask:img
});
thisPath.animate({fillOpacity: 1}, 200);
}
s.append(allPaths);
答案 0 :(得分:1)
确定!它已经解决了,这里是小提琴工作
https://jsfiddle.net/agevu82g/8/
var s = new Snap('.brushes'),
allPaths = s.selectAll("g");
allPaths.forEach(function(el) {
el.attr({
fillOpacity: 0,
fill: 'white'
});
});
allPaths.forEach( function(el, i ) {
var img = s.image('http://cf067b.medialib.glogster.com/media/60/607ef3f3255bd2db1e2444562b7468b595e287b42a1ea594ec8a98d30f7ce9f5/cute-kitten.jpg', 0, 0, 454, 322);
img.attr({ mask: el });
setTimeout( function() {
el.animate({fillOpacity: 1}, 2000);
}, i * 1000);
});