1
0
Fork 0

Add LinePart class

This commit is contained in:
Starbeamrainbowlabs 2017-03-31 18:58:47 +01:00
parent c5bef6dc52
commit 53c43f10fc
2 changed files with 16 additions and 24 deletions

View File

@ -33,28 +33,4 @@ class DrawnLine
*/
this.Points = [];
}
SplitOnChunks(chunkSize)
{
var results = [];
var nextLine = new DrawnLine(),
currentChunk = null;
for(let point of this.points)
{
if(currentChunk != null &&
!point.ContainingChunk(chunkSize).is(currentChunk))
{
// We're heading into a new chunk! Split the line up here.
// TODO: Add connecting lines to each DrawnLine instance to prevent gaps
results.push(nextLine);
nextLine = new DrawnLine(this.LineId);
}
nextLine.Points.push(point);
}
return results;
}
}

View File

@ -0,0 +1,16 @@
"use strict";
const cuid = require("cuid");
class LinePart
{
constructor()
{
this.LineId = cuid();
this.Points = [];
}
}
export default LinePart;