Permalink
Browse files

Add missing support for opacity (alpha) to gradients

Fixes issue #531
  • Loading branch information...
1 parent 2b0c5a2 commit 99288854e38868e1c163d41bb00b5f6d33c7b21a @neuhaus committed Mar 4, 2012
Showing with 5 additions and 3 deletions.
  1. +2 −1 raphael.core.js
  2. +3 −2 raphael.svg.js
View
@@ -879,7 +879,7 @@
green = toInt((t = rgb[3].charAt(2)) + t, 16);
red = toInt((t = rgb[3].charAt(1)) + t, 16);
}
- if (rgb[4]) {
+ if (rgb[4]) { // matched rgb(...) or rgba(...)
values = rgb[4][split](commaSpaces);
red = toFloat(values[0]);
values[0].slice(-1) == "%" && (red *= 2.55);
@@ -1660,6 +1660,7 @@
if (dot.color.error) {
return null;
}
+ dot.color.hasOwnProperty('opacity') && (dot.opacity = dot.color.opacity);
dot.color = dot.color.hex;
par[2] && (dot.offset = par[2] + "%");
dots.push(dot);
View
@@ -120,7 +120,8 @@ window.Raphael.svg && function (R) {
for (var i = 0, ii = dots.length; i < ii; i++) {
el.appendChild($("stop", {
offset: dots[i].offset ? dots[i].offset : i ? "100%" : "0%",
- "stop-color": dots[i].color || "#fff"
+ "stop-color": dots[i].color || "#fff",
+ "stop-opacity" : dots[i].hasOwnProperty('opacity') ? dots[i].opacity : 1
}));
}
}
@@ -1354,4 +1355,4 @@ window.Raphael.svg && function (R) {
};
})(method);
}
-}(window.Raphael);
+}(window.Raphael);

0 comments on commit 9928885

Please sign in to comment.