mirror of
https://github.com/lovasoa/whitebophir
synced 2024-11-10 14:34:20 +00:00
Use a pathData cache to improve rendering performance
This commit is contained in:
parent
13f2ebba63
commit
d75371c958
1 changed files with 11 additions and 1 deletions
|
@ -102,9 +102,19 @@
|
|||
return Math.hypot(x2 - x1, y2 - y1);
|
||||
}
|
||||
|
||||
var pathDataCache = {};
|
||||
function getPathData(line) {
|
||||
var pathData = pathDataCache[line.id];
|
||||
if (!pathData) {
|
||||
pathData = line.getPathData();
|
||||
pathDataCache[line.id] = pathData;
|
||||
}
|
||||
return pathData;
|
||||
}
|
||||
|
||||
var svg = Tools.svg;
|
||||
function addPoint(line, x, y) {
|
||||
var pts = line.getPathData(), //The points that are already in the line as a PathData
|
||||
var pts = getPathData(line), //The points that are already in the line as a PathData
|
||||
nbr = pts.length; //The number of points already in the line
|
||||
switch (nbr) {
|
||||
case 0: //The first point in the line
|
||||
|
|
Loading…
Reference in a new issue