Commit f1d24342 by Dmitry Baranovskiy

1.3.1 Fixed couple bugs with title, arc & subpath.

parent a8d0f3fa
...@@ -5,11 +5,13 @@ ...@@ -5,11 +5,13 @@
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
*/ */
if (Raphael.vml) { (function () {
if (Raphael.vml) {
var reg = / progid:\S+Blur\([^\)]+\)/g;
Raphael.el.blur = function (size) { Raphael.el.blur = function (size) {
var s = this.node.style, var s = this.node.style,
f = s.filter; f = s.filter;
f = f.replace(/ progid:\S+Blur\([^\)]+\)/g, ""); f = f.replace(reg, "");
if (size != "none") { if (size != "none") {
s.filter = f + " progid:DXImageTransform.Microsoft.Blur(pixelradius=" + (+size || 1.5) + ")"; 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)); s.margin = Raphael.format("-{0}px 0 0 -{0}px", Math.round(+size || 1.5));
...@@ -18,7 +20,16 @@ if (Raphael.vml) { ...@@ -18,7 +20,16 @@ if (Raphael.vml) {
s.margin = 0; s.margin = 0;
} }
}; };
} else { } 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) { Raphael.el.blur = function (size) {
// Experimental. No WebKit support. // Experimental. No WebKit support.
if (size != "none") { if (size != "none") {
...@@ -38,4 +49,5 @@ if (Raphael.vml) { ...@@ -38,4 +49,5 @@ if (Raphael.vml) {
this.node.removeAttribute("filter"); this.node.removeAttribute("filter");
} }
}; };
} }
\ No newline at end of file })();
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. * 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; r2 = r2 || r * .382;
rays = rays || 5; rays = rays || 5;
var points = ["M", cx, cy + r2, "L"], var points = ["M", cx, cy + r2, "L"],
...@@ -41,6 +41,14 @@ Raphael.fn.spike = function (cx, cy, rout, rin, n) { ...@@ -41,6 +41,14 @@ Raphael.fn.spike = function (cx, cy, rout, rin, n) {
points.push("z"); points.push("z");
return this.path(points); 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) { Raphael.fn.polygon = function (cx, cy, r, n) {
n = +n < 3 || !n ? 5 : n; n = +n < 3 || !n ? 5 : n;
var points = ["M", cx, cy - r, "L"], var points = ["M", cx, cy - r, "L"],
...@@ -86,6 +94,6 @@ Raphael.fn.plus = function (cx, cy, r) { ...@@ -86,6 +94,6 @@ Raphael.fn.plus = function (cx, cy, r) {
r = r / 2; 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"])); 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")); 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"));
}; };
This source diff could not be displayed because it is too large. You can view the blob instead.
/*! /*!
* Raphael 1.3.0 - JavaScript Vector Library * Raphael 1.3.1 - JavaScript Vector Library
* *
* Copyright (c) 2008 - 2009 Dmitry Baranovskiy (http://raphaeljs.com) * Copyright (c) 2008 - 2009 Dmitry Baranovskiy (http://raphaeljs.com)
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
*/ */
window.Raphael = (function () { Raphael = (function () {
var separator = /[, ]+/, var separator = /[, ]+/,
elements = /^(circle|rect|path|ellipse|text|image)$/, elements = /^(circle|rect|path|ellipse|text|image)$/,
doc = document, doc = document,
...@@ -61,7 +61,7 @@ window.Raphael = (function () { ...@@ -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}, 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}, 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"; 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"); R.type = (win.SVGAngle || doc.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") ? "SVG" : "VML");
if (R.type == "VML") { if (R.type == "VML") {
var d = document.createElement("div"); var d = document.createElement("div");
...@@ -575,6 +575,11 @@ window.Raphael = (function () { ...@@ -575,6 +575,11 @@ window.Raphael = (function () {
y = (y1 - y2) / 2; y = (y1 - y2) / 2;
rx = mmax(rx, math.abs(x)); rx = mmax(rx, math.abs(x));
ry = mmax(ry, math.abs(y)); 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, var rx2 = rx * rx,
ry2 = ry * ry, ry2 = ry * ry,
k = (large_arc_flag == sweep_flag ? -1 : 1) * k = (large_arc_flag == sweep_flag ? -1 : 1) *
...@@ -1077,7 +1082,7 @@ window.Raphael = (function () { ...@@ -1077,7 +1082,7 @@ window.Raphael = (function () {
hl[appendChild](node); hl[appendChild](node);
pn = hl; pn = hl;
} }
pn.setAttributeNS(o.Paper[proto].xlink, att, value); pn.setAttributeNS(o.paper.xlink, att, value);
break; break;
case "cursor": case "cursor":
node.style.cursor = value; node.style.cursor = value;
...@@ -2628,11 +2633,9 @@ window.Raphael = (function () { ...@@ -2628,11 +2633,9 @@ window.Raphael = (function () {
if (subpath && !subpaths.start) { if (subpath && !subpaths.start) {
point = R.findDotsAtSegment(x, y, p[1], p[2], p[3], p[4], p[5], p[6], (length - len) / l); 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]; sp += ["C", point.start.x, point.start.y, point.m.x, point.m.y, point.x, point.y];
if (onlystart) { if (onlystart) return sp;
return sp;
}
subpaths.start = 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; len += l;
x = +p[5]; x = +p[5];
y = +p[6]; y = +p[6];
...@@ -2678,6 +2681,9 @@ window.Raphael = (function () { ...@@ -2678,6 +2681,9 @@ window.Raphael = (function () {
}; };
Element[proto].getSubpath = function (from, to) { Element[proto].getSubpath = function (from, to) {
if (this.type != "path") return; 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); var a = getSubpathsAtLength(this.attrs.path, to, 1);
return from ? getSubpathsAtLength(a, from).end : a; return from ? getSubpathsAtLength(a, from).end : a;
}; };
...@@ -3198,15 +3204,11 @@ window.Raphael = (function () { ...@@ -3198,15 +3204,11 @@ window.Raphael = (function () {
return token || E; return token || E;
}; };
R.ninja = function () { R.ninja = function () {
var r = win.Raphael, u; var r = Raphael;
if (oldRaphael.was) { if (oldRaphael.was) {
win.Raphael = oldRaphael.is; Raphael = oldRaphael.is;
} else { } else {
try { delete Raphael;
delete win.Raphael;
} catch (e) {
win.Raphael = u;
}
} }
return r; return r;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment