mirror of
https://github.com/sbrl/Nibriboard.git
synced 2018-01-10 21:33:49 +00:00
[client] Get chunks to account for position on canvas
This commit is contained in:
parent
6a0d3180a7
commit
00117a35a9
2 changed files with 9 additions and 6 deletions
|
@ -40,20 +40,23 @@ class Chunk
|
|||
|
||||
render(canvas, context)
|
||||
{
|
||||
var planeSpaceRef = this.chunkRef.inPlaneSpace(this.size);
|
||||
|
||||
context.save();
|
||||
context.translate(planeSpaceRef.x, planeSpaceRef.y);
|
||||
|
||||
for(let line of this.lines)
|
||||
{
|
||||
context.beginPath();
|
||||
context.moveTo(
|
||||
line.Points[0].x - this.chunkRef.inPlaneSpace(this.size).x,
|
||||
line.Points[0].y - this.chunkRef.inPlaneSpace(this.size).y
|
||||
line.Points[0].x - planeSpaceRef.x,
|
||||
line.Points[0].y - planeSpaceRef.y
|
||||
);
|
||||
for(let i = 1; i < line.Points.length; i++)
|
||||
{
|
||||
context.lineTo(
|
||||
line.Points[i].x - this.chunkRef.inPlaneSpace(this.size).x,
|
||||
line.Points[i].y - this.chunkRef.inPlaneSpace(this.size).y
|
||||
line.Points[i].x - planeSpaceRef.x,
|
||||
line.Points[i].y - planeSpaceRef.y
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ class ChunkReference extends Vector
|
|||
|
||||
/**
|
||||
* Returns a plain Vector of this chunk reference in plane space.
|
||||
* @param {number} chunkSize The size of the chunk this ChunkReference refers to.
|
||||
* @return {Vector} This ChunkReference in plane space.
|
||||
* @param {number} chunkSize The size of the chunk this ChunkReference refers to.
|
||||
* @returns {Vector} This ChunkReference in plane space.
|
||||
*/
|
||||
inPlaneSpace(chunkSize)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue