Commit 89e3f477 by 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.
......@@ -18,7 +18,8 @@ window.Raphael.svg && function (R) {
pow = math.pow,
separator = /[, ]+/,
eve = R.eve,
E = "";
E = "",
S = " ";
// SVG
var xlink = "http://www.w3.org/1999/xlink",
markers = {
......@@ -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) {
var 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]
},
node = o.node,
var node = o.node,
attrs = o.attrs,
addDashes = function (o, value) {
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;
}
$(node, {"stroke-dasharray": dashes.join(",")});
}
};
vis = node.style.visibility;
node.style.visibility = "hidden";
for (var att in params) {
if (params[has](att)) {
if (!R._availableAttrs[has](att)) {
......@@ -455,7 +458,7 @@ window.Raphael.svg && function (R) {
}
node.setAttribute(att, value);
if (attrs["stroke-dasharray"]) {
addDashes(o, attrs["stroke-dasharray"]);
addDashes(o, attrs["stroke-dasharray"], params);
}
if (o._.arrows) {
"startString" in o._.arrows && addArrow(o, o._.arrows.startString);
......@@ -463,7 +466,7 @@ window.Raphael.svg && function (R) {
}
break;
case "stroke-dasharray":
addDashes(o, value);
addDashes(o, value, params);
break;
case "fill":
var isURL = Str(value).match(R._ISURL);
......@@ -554,6 +557,7 @@ window.Raphael.svg && function (R) {
}
tuneText(o, params);
node.style.visibility = vis;
},
leading = 1.2,
tuneText = function (el, params) {
......@@ -686,7 +690,11 @@ window.Raphael.svg && function (R) {
SVG.canvas && SVG.canvas.appendChild(el);
var p = new Element(el, SVG);
p.type = "path";
setFillAndStroke(p, {fill: "none", stroke: "#000", path: pathString});
setFillAndStroke(p, {
fill: "none",
stroke: "#000",
path: pathString
});
return p;
};
/*\
......@@ -965,7 +973,7 @@ window.Raphael.svg && function (R) {
# <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(•••%, •••%, •••%) — 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>
# </ul>
\*/
......
......@@ -33,7 +33,7 @@ window.Raphael.vml && function (R) {
path2vml = function (path) {
var total = /[ahqstv]/ig,
command = R._pathToAbsolute;
Str(path).match(total) && (command = path2curve);
Str(path).match(total) && (command = R._path2curve);
total = /[clmz]/g;
if (command == R._pathToAbsolute && !Str(path).match(total)) {
var res = Str(path).replace(bites, function (all, command, args) {
......@@ -333,7 +333,7 @@ window.Raphael.vml && function (R) {
var brect = span.getBoundingClientRect();
res.W = a.w = (brect.right - brect.left) / 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.Y = a.y + res.H / 2;
......@@ -811,7 +811,12 @@ window.Raphael.vml && function (R) {
el.coordsize = zoom + S + zoom;
el.coordorigin = "0 0";
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.path = path;
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 sign in to comment