Commit 89e3f477 authored by Dmitry Baranovskiy's avatar Dmitry Baranovskiy

Bug fixes & docs update

• documentation for Cufon fonts • fixed path2curve error • fixed setSize
and setViewBox
parent 68d4b8fb
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
...@@ -18,7 +18,8 @@ window.Raphael.svg && function (R) { ...@@ -18,7 +18,8 @@ window.Raphael.svg && function (R) {
pow = math.pow, pow = math.pow,
separator = /[, ]+/, separator = /[, ]+/,
eve = R.eve, eve = R.eve,
E = ""; E = "",
S = " ";
// SVG // SVG
var xlink = "http://www.w3.org/1999/xlink", var xlink = "http://www.w3.org/1999/xlink",
markers = { markers = {
...@@ -285,36 +286,38 @@ window.Raphael.svg && function (R) { ...@@ -285,36 +286,38 @@ window.Raphael.svg && function (R) {
} }
} }
}, },
dasharray = {
"": [0],
"none": [0],
"-": [3, 1],
".": [1, 1],
"-.": [3, 1, 1, 1],
"-..": [3, 1, 1, 1, 1, 1],
". ": [1, 3],
"- ": [4, 3],
"--": [8, 3],
"- .": [4, 3, 1, 3],
"--.": [8, 3, 1, 3],
"--..": [8, 3, 1, 3, 1, 3]
},
addDashes = function (o, value, params) {
value = dasharray[Str(value).toLowerCase()];
if (value) {
var width = o.attrs["stroke-width"] || "1",
butt = {round: width, square: width, butt: 0}[o.attrs["stroke-linecap"] || params["stroke-linecap"]] || 0,
dashes = [],
i = value.length;
while (i--) {
dashes[i] = value[i] * width + ((i % 2) ? 1 : -1) * butt;
}
$(o.node, {"stroke-dasharray": dashes.join(",")});
}
},
setFillAndStroke = function (o, params) { setFillAndStroke = function (o, params) {
var dasharray = { var node = o.node,
"": [0],
"none": [0],
"-": [3, 1],
".": [1, 1],
"-.": [3, 1, 1, 1],
"-..": [3, 1, 1, 1, 1, 1],
". ": [1, 3],
"- ": [4, 3],
"--": [8, 3],
"- .": [4, 3, 1, 3],
"--.": [8, 3, 1, 3],
"--..": [8, 3, 1, 3, 1, 3]
},
node = o.node,
attrs = o.attrs, attrs = o.attrs,
addDashes = function (o, value) { vis = node.style.visibility;
value = dasharray[Str(value).toLowerCase()]; node.style.visibility = "hidden";
if (value) {
var width = o.attrs["stroke-width"] || "1",
butt = {round: width, square: width, butt: 0}[o.attrs["stroke-linecap"] || params["stroke-linecap"]] || 0,
dashes = [],
i = value.length;
while (i--) {
dashes[i] = value[i] * width + ((i % 2) ? 1 : -1) * butt;
}
$(node, {"stroke-dasharray": dashes.join(",")});
}
};
for (var att in params) { for (var att in params) {
if (params[has](att)) { if (params[has](att)) {
if (!R._availableAttrs[has](att)) { if (!R._availableAttrs[has](att)) {
...@@ -455,7 +458,7 @@ window.Raphael.svg && function (R) { ...@@ -455,7 +458,7 @@ window.Raphael.svg && function (R) {
} }
node.setAttribute(att, value); node.setAttribute(att, value);
if (attrs["stroke-dasharray"]) { if (attrs["stroke-dasharray"]) {
addDashes(o, attrs["stroke-dasharray"]); addDashes(o, attrs["stroke-dasharray"], params);
} }
if (o._.arrows) { if (o._.arrows) {
"startString" in o._.arrows && addArrow(o, o._.arrows.startString); "startString" in o._.arrows && addArrow(o, o._.arrows.startString);
...@@ -463,7 +466,7 @@ window.Raphael.svg && function (R) { ...@@ -463,7 +466,7 @@ window.Raphael.svg && function (R) {
} }
break; break;
case "stroke-dasharray": case "stroke-dasharray":
addDashes(o, value); addDashes(o, value, params);
break; break;
case "fill": case "fill":
var isURL = Str(value).match(R._ISURL); var isURL = Str(value).match(R._ISURL);
...@@ -554,6 +557,7 @@ window.Raphael.svg && function (R) { ...@@ -554,6 +557,7 @@ window.Raphael.svg && function (R) {
} }
tuneText(o, params); tuneText(o, params);
node.style.visibility = vis;
}, },
leading = 1.2, leading = 1.2,
tuneText = function (el, params) { tuneText = function (el, params) {
...@@ -686,7 +690,11 @@ window.Raphael.svg && function (R) { ...@@ -686,7 +690,11 @@ window.Raphael.svg && function (R) {
SVG.canvas && SVG.canvas.appendChild(el); SVG.canvas && SVG.canvas.appendChild(el);
var p = new Element(el, SVG); var p = new Element(el, SVG);
p.type = "path"; p.type = "path";
setFillAndStroke(p, {fill: "none", stroke: "#000", path: pathString}); setFillAndStroke(p, {
fill: "none",
stroke: "#000",
path: pathString
});
return p; return p;
}; };
/*\ /*\
...@@ -965,7 +973,7 @@ window.Raphael.svg && function (R) { ...@@ -965,7 +973,7 @@ window.Raphael.svg && function (R) {
# <li>hsba(•••, •••, •••, •••) — same as above, but with opacity</li> # <li>hsba(•••, •••, •••, •••) — same as above, but with opacity</li>
# <li>hsl(•••, •••, •••) — almost the same as hsb, see <a href="http://en.wikipedia.org/wiki/HSL_and_HSV" title="HSL and HSV - Wikipedia, the free encyclopedia">Wikipedia page</a></li> # <li>hsl(•••, •••, •••) — almost the same as hsb, see <a href="http://en.wikipedia.org/wiki/HSL_and_HSV" title="HSL and HSV - Wikipedia, the free encyclopedia">Wikipedia page</a></li>
# <li>hsl(•••%, •••%, •••%) — same as above, but in %</li> # <li>hsl(•••%, •••%, •••%) — same as above, but in %</li>
# <li>hsla(•••, •••, •••) — same as above, but with opacity</li> # <li>hsla(•••, •••, •••, •••) — same as above, but with opacity</li>
# <li>Optionally for hsb and hsl you could specify hue as a degree: “<code>hsl(240deg,&nbsp;1,&nbsp;.5)</code>” or, if you want to go fancy, “<code>hsl(240°,&nbsp;1,&nbsp;.5)</code>”</li> # <li>Optionally for hsb and hsl you could specify hue as a degree: “<code>hsl(240deg,&nbsp;1,&nbsp;.5)</code>” or, if you want to go fancy, “<code>hsl(240°,&nbsp;1,&nbsp;.5)</code>”</li>
# </ul> # </ul>
\*/ \*/
......
...@@ -33,7 +33,7 @@ window.Raphael.vml && function (R) { ...@@ -33,7 +33,7 @@ window.Raphael.vml && function (R) {
path2vml = function (path) { path2vml = function (path) {
var total = /[ahqstv]/ig, var total = /[ahqstv]/ig,
command = R._pathToAbsolute; command = R._pathToAbsolute;
Str(path).match(total) && (command = path2curve); Str(path).match(total) && (command = R._path2curve);
total = /[clmz]/g; total = /[clmz]/g;
if (command == R._pathToAbsolute && !Str(path).match(total)) { if (command == R._pathToAbsolute && !Str(path).match(total)) {
var res = Str(path).replace(bites, function (all, command, args) { var res = Str(path).replace(bites, function (all, command, args) {
...@@ -333,7 +333,7 @@ window.Raphael.vml && function (R) { ...@@ -333,7 +333,7 @@ window.Raphael.vml && function (R) {
var brect = span.getBoundingClientRect(); var brect = span.getBoundingClientRect();
res.W = a.w = (brect.right - brect.left) / m; res.W = a.w = (brect.right - brect.left) / m;
res.H = a.h = (brect.bottom - brect.top) / m; res.H = a.h = (brect.bottom - brect.top) / m;
res.paper.canvas.style.display = "none"; // res.paper.canvas.style.display = "none";
res.X = a.x; res.X = a.x;
res.Y = a.y + res.H / 2; res.Y = a.y + res.H / 2;
...@@ -811,7 +811,12 @@ window.Raphael.vml && function (R) { ...@@ -811,7 +811,12 @@ window.Raphael.vml && function (R) {
el.coordsize = zoom + S + zoom; el.coordsize = zoom + S + zoom;
el.coordorigin = "0 0"; el.coordorigin = "0 0";
var p = new Element(el, vml), var p = new Element(el, vml),
attr = {fill: "#000", stroke: "none", font: availableAttrs.font, text: text}; attr = {
fill: "#000",
stroke: "none",
font: R._availableAttrs.font,
text: text
};
p.shape = el; p.shape = el;
p.path = path; p.path = path;
p.textpath = o; p.textpath = o;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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 to comment