|
|
|
@ -213,7 +213,8 @@ function mousedown(e, state, context) {
@@ -213,7 +213,8 @@ function mousedown(e, state, context) {
|
|
|
|
|
|
|
|
|
|
schedule_draw(state, context); |
|
|
|
|
} else if (state.tools.active === 'ruler') { |
|
|
|
|
|
|
|
|
|
state.linedrawing = true; |
|
|
|
|
state.ruler_origin = canvasp; |
|
|
|
|
} else if (state.tools.active === 'eraser') { |
|
|
|
|
state.erasing = true; |
|
|
|
|
} else if (state.tools.active === 'pointer') { |
|
|
|
@ -412,6 +413,19 @@ function mousemove(e, state, context) {
@@ -412,6 +413,19 @@ function mousemove(e, state, context) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (state.linedrawing) { |
|
|
|
|
// TODO: we should do something different when we allow multiple dynamic strokes per player
|
|
|
|
|
geometry_clear_player(state, context, state.me); |
|
|
|
|
|
|
|
|
|
const p1 = {'x': state.ruler_origin.x, 'y': state.ruler_origin.y, 'pressure': 128}; |
|
|
|
|
const p2 = {'x': canvasp.x, 'y': canvasp.y, 'pressure': 128}; |
|
|
|
|
|
|
|
|
|
geometry_add_point(state, context, state.me, p1, false, true); |
|
|
|
|
geometry_add_point(state, context, state.me, p2, false, true); |
|
|
|
|
|
|
|
|
|
do_draw = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (do_draw) { |
|
|
|
|
schedule_draw(state, context); |
|
|
|
|
} |
|
|
|
@ -482,6 +496,13 @@ function mouseup(e, state, context) {
@@ -482,6 +496,13 @@ function mouseup(e, state, context) {
|
|
|
|
|
state.erasing = false; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (state.linedrawing) { |
|
|
|
|
state.linedrawing = false; |
|
|
|
|
queue_event(state, stroke_event(state)); |
|
|
|
|
schedule_draw(state, context); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function mouseleave(e, state, context) { |
|
|
|
@ -507,7 +528,7 @@ function update_cursor(state) {
@@ -507,7 +528,7 @@ function update_cursor(state) {
|
|
|
|
|
|
|
|
|
|
let svg; |
|
|
|
|
|
|
|
|
|
if (state.tools.active === 'pencil') { |
|
|
|
|
if (state.tools.active === 'pencil' || state.tools.active === 'ruler') { |
|
|
|
|
const current_color = color_from_u32(me.color); |
|
|
|
|
const stroke = (me.color === 0xFFFFFF ? 'black' : 'white'); |
|
|
|
|
|
|
|
|
|