Skip to content

Commit

Permalink
Fix: drawing while zoomed places in the center of the zoomed part
Browse files Browse the repository at this point in the history
  • Loading branch information
cgloeckner committed Jul 3, 2022
1 parent 28a822b commit 4f0e5f1
Showing 1 changed file with 2 additions and 51 deletions.
53 changes: 2 additions & 51 deletions static/drawing.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,55 +252,6 @@ function onReleasePen(event) {
null, null,
width, color
)

/*
var canvas = $('#doodle')[0];
var context = canvas.getContext("2d");
// get mouse position with canvas (and consider hardcoded zoom)
var box = canvas.getBoundingClientRect()
var x = (event.clientX - box.left) * 2
var y = (event.clientY - box.top) * 2
if (event.shiftKey && line_from != null) {
var width = parseInt($('#penwidth')[0].value);
var color = $('#pencolor')[0].value;
// draw straight line
context.strokeStyle = color;
context.fillStyle = color;
context.lineWidth = width;
context.lineCap = "round";
context.beginPath()
context.moveTo(line_from[0], line_from[1])
context.lineTo(x, y)
context.stroke()
}
line_from = [x, y];
if (pen_pos.length > 1) {
// redraw entire line smoothly
context.beginPath();
for (var i = 0; i < pen_pos.length; ++i) {
if (i == 0) {
context.moveTo(pen_pos[i][0], pen_pos[i][1]);
} else {
context.lineTo(pen_pos[i][0], pen_pos[i][1]);
}
}
context.stroke();
} else if (pen_pos.length == 1) {
// draw dot
context.beginPath();
context.moveTo(pen_pos[0][0], pen_pos[0][1]);
context.lineTo(pen_pos[0][0]+1, pen_pos[0][1]+1);
context.stroke();
}
pen_pos = [];
*/
}

/// Modify line width using the mouse wheel
Expand Down Expand Up @@ -344,8 +295,8 @@ function onUploadDrawing() {

} else {
// upload as token at screen center
var x = Math.round(MAX_SCENE_WIDTH / 2)
var y = Math.round(MAX_SCENE_HEIGHT / 2);
var x = Math.round(viewport.x)
var y = Math.round(viewport.y)
uploadFiles(gm_name, game_url, f, [], x, y);
}

Expand Down

0 comments on commit 4f0e5f1

Please sign in to comment.