Added caching and fix for bug #15

master
Dmitry Baranovskiy 2013-09-19 09:33:01 +10:00
parent 7e29cfe537
commit d4182d9318
1 changed files with 4 additions and 3 deletions

View File

@ -89,7 +89,7 @@ Savage.plugin(function (Savage, Element, Paper, glob) {
function O(val) { function O(val) {
return +(+val).toFixed(3); return +(+val).toFixed(3);
} }
return function (path, length, onlystart) { return Savage._.cacher(function (path, length, onlystart) {
if (path instanceof Element) { if (path instanceof Element) {
path = path.attr("d"); path = path.attr("d");
} }
@ -144,7 +144,7 @@ Savage.plugin(function (Savage, Element, Paper, glob) {
subpaths.end = sp; subpaths.end = sp;
point = istotal ? len : subpath ? subpaths : findDotsAtSegment(x, y, p[0], p[1], p[2], p[3], p[4], p[5], 1); point = istotal ? len : subpath ? subpaths : findDotsAtSegment(x, y, p[0], p[1], p[2], p[3], p[4], p[5], 1);
return point; return point;
}; }, null, Savage._.clone);
} }
var getTotalLength = getLengthFactory(1), var getTotalLength = getLengthFactory(1),
getPointAtLength = getLengthFactory(), getPointAtLength = getLengthFactory(),
@ -525,7 +525,8 @@ Savage.plugin(function (Savage, Element, Paper, glob) {
} }
}; };
function pathToRelative(pathArray) { function pathToRelative(pathArray) {
var pth = paths(pathArray); var pth = paths(pathArray),
lowerCase = String.prototype.toLowerCase;
if (pth.rel) { if (pth.rel) {
return pathClone(pth.rel); return pathClone(pth.rel);
} }