Skip to content

Commit

Permalink
1.3.1 Fixed couple bugs with title, arc & subpath.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Baranovskiy authored and Dmitry Baranovskiy committed Jan 18, 2010
1 parent a8d0f3f commit f1d2434
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 52 deletions.
78 changes: 45 additions & 33 deletions plugins/raphael.blur.js
Expand Up @@ -5,37 +5,49 @@
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
*/

if (Raphael.vml) {
Raphael.el.blur = function (size) {
var s = this.node.style,
f = s.filter;
f = f.replace(/ progid:\S+Blur\([^\)]+\)/g, "");
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 {
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;
(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;
}
this.node.removeAttribute("filter");
}
};
}
};
} 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");
}
};
}
})();
12 changes: 10 additions & 2 deletions plugins/raphael.primitives.js
Expand Up @@ -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"],
Expand Down Expand Up @@ -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"],
Expand Down Expand Up @@ -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"));
};
4 changes: 2 additions & 2 deletions raphael-min.js

Large diffs are not rendered by default.

32 changes: 17 additions & 15 deletions raphael.js
@@ -1,12 +1,12 @@
/*!
* Raphael 1.3.0 - JavaScript Vector Library
* Raphael 1.3.1 - JavaScript Vector Library
*
* Copyright (c) 2008 - 2009 Dmitry Baranovskiy (http://raphaeljs.com)
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
*/


window.Raphael = (function () {
Raphael = (function () {
var separator = /[, ]+/,
elements = /^(circle|rect|path|ellipse|text|image)$/,
doc = document,
Expand Down Expand Up @@ -61,7 +61,7 @@ window.Raphael = (function () {
availableAttrs = {"clip-rect": "0 0 1e9 1e9", cursor: "default", cx: 0, cy: 0, fill: "#fff", "fill-opacity": 1, font: '10px "Arial"', "font-family": '"Arial"', "font-size": "10", "font-style": "normal", "font-weight": 400, gradient: 0, height: 0, href: "http://raphaeljs.com/", opacity: 1, path: "M0,0", r: 0, rotation: 0, rx: 0, ry: 0, scale: "1 1", src: "", stroke: "#000", "stroke-dasharray": "", "stroke-linecap": "butt", "stroke-linejoin": "butt", "stroke-miterlimit": 0, "stroke-opacity": 1, "stroke-width": 1, target: "_blank", "text-anchor": "middle", title: "Raphael", translation: "0 0", width: 0, x: 0, y: 0},
availableAnimAttrs = {along: "along", "clip-rect": "csv", cx: nu, cy: nu, fill: "colour", "fill-opacity": nu, "font-size": nu, height: nu, opacity: nu, path: "path", r: nu, rotation: "csv", rx: nu, ry: nu, scale: "csv", stroke: "colour", "stroke-opacity": nu, "stroke-width": nu, translation: "csv", width: nu, x: nu, y: nu},
rp = "replace";
R.version = "1.3.0";
R.version = "1.3.1";
R.type = (win.SVGAngle || doc.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") ? "SVG" : "VML");
if (R.type == "VML") {
var d = document.createElement("div");
Expand Down Expand Up @@ -575,6 +575,11 @@ window.Raphael = (function () {
y = (y1 - y2) / 2;
rx = mmax(rx, math.abs(x));
ry = mmax(ry, math.abs(y));
var h = (x * x) / (rx * rx) + (y * y) / (ry * ry);
if (h > 1){
rx = math.sqrt(h) * rx;
ry = math.sqrt(h) * ry;
}
var rx2 = rx * rx,
ry2 = ry * ry,
k = (large_arc_flag == sweep_flag ? -1 : 1) *
Expand Down Expand Up @@ -1077,7 +1082,7 @@ window.Raphael = (function () {
hl[appendChild](node);
pn = hl;
}
pn.setAttributeNS(o.Paper[proto].xlink, att, value);
pn.setAttributeNS(o.paper.xlink, att, value);
break;
case "cursor":
node.style.cursor = value;
Expand Down Expand Up @@ -2628,11 +2633,9 @@ window.Raphael = (function () {
if (subpath && !subpaths.start) {
point = R.findDotsAtSegment(x, y, p[1], p[2], p[3], p[4], p[5], p[6], (length - len) / l);
sp += ["C", point.start.x, point.start.y, point.m.x, point.m.y, point.x, point.y];
if (onlystart) {
return sp;
}
if (onlystart) return sp;
subpaths.start = sp;
sp = ["M", point.x, point.y, "C", point.n.x, point.n.y, point.end.x, point.end.y, p[5], p[6]][join]();
sp = ["M", point.x, point.y + "C", point.n.x, point.n.y, point.end.x, point.end.y, p[5], p[6]][join]();
len += l;
x = +p[5];
y = +p[6];
Expand Down Expand Up @@ -2678,6 +2681,9 @@ window.Raphael = (function () {
};
Element[proto].getSubpath = function (from, to) {
if (this.type != "path") return;
if (math.abs(this.getTotalLength() - to) < 1e-6) {
return getSubpathsAtLength(this.attrs.path, from).end;
}
var a = getSubpathsAtLength(this.attrs.path, to, 1);
return from ? getSubpathsAtLength(a, from).end : a;
};
Expand Down Expand Up @@ -3198,15 +3204,11 @@ window.Raphael = (function () {
return token || E;
};
R.ninja = function () {
var r = win.Raphael, u;
var r = Raphael;
if (oldRaphael.was) {
win.Raphael = oldRaphael.is;
Raphael = oldRaphael.is;
} else {
try {
delete win.Raphael;
} catch (e) {
win.Raphael = u;
}
delete Raphael;
}
return r;
};
Expand Down

0 comments on commit f1d2434

Please sign in to comment.