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:
parent
c5bef6dc52
commit
53c43f10fc
2 changed files with 16 additions and 24 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
16
Nibriboard/ClientFiles/RippleSpace/LinePart.js
Normal file
16
Nibriboard/ClientFiles/RippleSpace/LinePart.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
"use strict";
|
||||
|
||||
const cuid = require("cuid");
|
||||
|
||||
class LinePart
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
this.LineId = cuid();
|
||||
this.Points = [];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
export default LinePart;
|
Loading…
Reference in a new issue