Gradient transparency of object in RaphaelJS

一曲冷凌霜 提交于 2019-12-11 05:42:46

问题


I'm trying to get a rectangle partly transparent where the left part is opaque while the right part is more transparent if you go into that direction.

This works in Firefox, Chrome but not in Internet Explorer 7 or IE8. In IE all rectangles are displayed with the same transparent gradient.

function drawTest(y, pct) {
    var recttest = paper.rect(25,y,100,30);
    var gradstr = "0.0-#db38cc:5-#db38cc:"+pct;
    recttest.attr({"fill": gradstr,"opacity": "0.01"});
}
$(document).ready(function() {
        paper = Raphael(10,100, 400, 400);
        drawTest(0, 30);
        drawTest(50, 40);
        drawTest(100, 50);
        drawTest(150, 60);
        drawTest(200, 70);
        drawTest(250, 80);
});

See here for an example of above code running.

So how can I fix this for IE? Note that I want to put the rectangles on top of an image so it must be transparent (not white).


回答1:


This can’t be fixed. It is a limitation of VML and Raphaël.

However you can reduce width of the rectangle to get desired effect. To get semitransparent rect you should apply .attr({fill: "0-#000-#000", opacity: 0}); and then play with a width of the rectangle.



来源:https://stackoverflow.com/questions/3099247/gradient-transparency-of-object-in-raphaeljs

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