From: Dmitry Baranovskiy Date: Fri, 2 Jul 2010 12:36:45 +0000 (+1000) Subject: Fixed bug with path parsing and blur in IE X-Git-Tag: v1.4.4 X-Git-Url: http://git.roojs.org/?p=raphael;a=commitdiff_plain;h=03538da207cb41e2ebc303fe8fc247dd0b5e655f;hp=523c811e91fab6fb465f463d38772c0396edb4da Fixed bug with path parsing and blur in IE --- diff --git a/plugins/raphael.blur.js b/plugins/raphael.blur.js new file mode 100644 index 0000000..2484641 --- /dev/null +++ b/plugins/raphael.blur.js @@ -0,0 +1,53 @@ +/*! + * Raphael Blur Plugin 0.1 + * + * Copyright (c) 2009 Dmitry Baranovskiy (http://raphaeljs.com) + * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. + */ + +(function () { + if (Raphael.vml) { + var reg = / progid:\S+Blur\([^\)]+\)/g; + Raphael.el.blur = function (size) { + var s = this.node.style, + f = s.filter; + f = f.replace(reg, ""); + if (size != "none") { + s.filter = f + " progid:DXImageTransform.Microsoft.Blur(pixelradius=" + (+size || 1.5) + ")"; + s.margin = Raphael.format("-{0}px 0 0 -{0}px", Math.round(+size || 1.5)); + } else { + s.filter = f; + s.margin = 0; + } + }; + } else { + var $ = function (el, attr) { + if (attr) { + for (var key in attr) if (attr.hasOwnProperty(key)) { + el.setAttribute(key, attr[key]); + } + } else { + return doc.createElementNS("http://www.w3.org/2000/svg", el); + } + }; + Raphael.el.blur = function (size) { + // Experimental. No WebKit support. + if (size != "none") { + var fltr = $("filter"), + blur = $("feGaussianBlur"); + fltr.id = "r" + (Raphael.idGenerator++).toString(36); + $(blur, {stdDeviation: +size || 1.5}); + fltr.appendChild(blur); + this.paper.defs.appendChild(fltr); + this._blur = fltr; + $(this.node, {filter: "url(#" + fltr.id + ")"}); + } else { + if (this._blur) { + this._blur.parentNode.removeChild(this._blur); + delete this._blur; + } + this.node.removeAttribute("filter"); + } + }; + } +})(); \ No newline at end of file diff --git a/plugins/raphael.primitives.js b/plugins/raphael.primitives.js index af752cf..7104f79 100644 --- a/plugins/raphael.primitives.js +++ b/plugins/raphael.primitives.js @@ -5,7 +5,7 @@ * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. */ -Raphael.fn.g.star = function (cx, cy, r, r2, rays) { +Raphael.fn.star = function (cx, cy, r, r2, rays) { r2 = r2 || r * .382; rays = rays || 5; var points = ["M", cx, cy + r2, "L"], @@ -41,6 +41,14 @@ Raphael.fn.spike = function (cx, cy, rout, rin, n) { points.push("z"); return this.path(points); }; +Raphael.fn.polyline = function () { + var points = "M".concat(arguments[0] || 0, ",", arguments[1] || 0, "L"); + for (var i = 2, ii = arguments.length - 1; i < ii; i++) { + points += arguments[i] + "," + arguments[++i]; + } + arguments[ii].toLowerCase() == "z" && (points += "z"); + return this.path(points); +}; Raphael.fn.polygon = function (cx, cy, r, n) { n = +n < 3 || !n ? 5 : n; var points = ["M", cx, cy - r, "L"], @@ -86,6 +94,6 @@ Raphael.fn.plus = function (cx, cy, r) { r = r / 2; return this.path("M".concat(cx - r / 2, ",", cy - r / 2, "l", [0, -r, r, 0, 0, r, r, 0, 0, r, -r, 0, 0, r, -r, 0, 0, -r, -r, 0, 0, -r, "z"])); }; -Raphael.fn.g.arrow = function (cx, cy, r) { +Raphael.fn.arrow = function (cx, cy, r) { return this.path("M".concat(cx - r * .7, ",", cy - r * .4, "l", [r * .6, 0, 0, -r * .4, r, r * .8, -r, r * .8, 0, -r * .4, -r * .6, 0], "z")); };