1
0
Fork 0
mirror of https://github.com/sbrl/Nibriboard.git synced 2018-01-10 21:33:49 +00:00

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;