mirror of
https://github.com/sbrl/Nibriboard.git
synced 2018-01-10 21:33:49 +00:00
Fix pencil live preview and more zomming issues
This commit is contained in:
parent
70ed434f1b
commit
636bc0535a
3 changed files with 16 additions and 6 deletions
|
@ -236,7 +236,7 @@ class BoardWindow extends EventEmitter
|
||||||
this.renderOthers(canvas, context);
|
this.renderOthers(canvas, context);
|
||||||
// Render the currently active line
|
// Render the currently active line
|
||||||
if(typeof this.pencil !== "undefined")
|
if(typeof this.pencil !== "undefined")
|
||||||
this.pencil.render(canvas, context);
|
this.pencil.render(this.viewport, canvas, context);
|
||||||
|
|
||||||
context.restore();
|
context.restore();
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ class Chunk
|
||||||
}
|
}
|
||||||
|
|
||||||
context.lineCap = "round";
|
context.lineCap = "round";
|
||||||
|
context.lineJoin = "round";
|
||||||
context.lineWidth = line.Width;
|
context.lineWidth = line.Width;
|
||||||
context.strokeStyle = line.Colour;
|
context.strokeStyle = line.Colour;
|
||||||
context.stroke();
|
context.stroke();
|
||||||
|
|
|
@ -143,19 +143,28 @@ class Pencil
|
||||||
* @param {HTMLCanvasElement} canvas The canvas to draw to.
|
* @param {HTMLCanvasElement} canvas The canvas to draw to.
|
||||||
* @param {CanvasRenderingContext2D} context The rendering context to use to draw to the canvas.
|
* @param {CanvasRenderingContext2D} context The rendering context to use to draw to the canvas.
|
||||||
*/
|
*/
|
||||||
render(canvas, context) {
|
render(visibleArea, canvas, context) {
|
||||||
if(this.currentLineSegments.length == 0)
|
if(this.currentLineSegments.length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
context.save();
|
context.save();
|
||||||
|
|
||||||
|
context.translate(
|
||||||
|
-visibleArea.x,
|
||||||
|
-visibleArea.y
|
||||||
|
);
|
||||||
|
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
context.lineTo(this.currentLineSegments[0].x, this.currentLineSegments[0].y);
|
context.moveTo(this.currentLineSegments[0].x, this.currentLineSegments[0].y);
|
||||||
for(let point of this.currentLineSegments) {
|
for(let i = 1; i < this.currentLineSegments.length; i++) {
|
||||||
context.lineTo(point.x, point.y);
|
context.lineTo(this.currentLineSegments[i].x, this.currentLineSegments[i].y);
|
||||||
}
|
}
|
||||||
context.lineWidth = this.currentColour;
|
|
||||||
|
context.lineWidth = this.currentLineWidth;
|
||||||
context.strokeStyle = this.currentColour;
|
context.strokeStyle = this.currentColour;
|
||||||
|
context.lineCap = "round";
|
||||||
|
context.lineJoin = "round";
|
||||||
|
context.stroke();
|
||||||
|
|
||||||
context.restore();
|
context.restore();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue