You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.0 KiB
41 lines
1.0 KiB
function draw_stroke(stroke) { |
|
const points = stroke.points; |
|
|
|
if (points.length === 0) { |
|
return; |
|
} |
|
|
|
// console.debug(points) |
|
|
|
storage.ctx0.beginPath(); |
|
storage.ctx0.moveTo(points[0].x, points[0].y); |
|
|
|
for (let i = 1; i < points.length; ++i) { |
|
const p = points[i]; |
|
storage.ctx0.lineTo(p.x, p.y); |
|
} |
|
|
|
storage.ctx0.stroke(); |
|
} |
|
|
|
function redraw_predraw() { |
|
storage.ctx1.clearRect(0, 0, storage.ctx1.canvas.width, storage.ctx1.canvas.height); |
|
} |
|
|
|
function predraw_user(user_id, event) { |
|
if (!(user_id in storage.predraw)) { |
|
storage.predraw[user_id] = []; |
|
} |
|
|
|
storage.ctx1.beginPath(); |
|
if (storage.predraw[user_id].length > 0) { |
|
const last = storage.predraw[user_id][storage.predraw[user_id].length - 1]; |
|
storage.ctx1.moveTo(last.x, last.y); |
|
storage.ctx1.lineTo(event.x, event.y); |
|
} else { |
|
storage.ctx1.moveTo(event.x, event.y); |
|
} |
|
storage.ctx1.stroke(); |
|
|
|
storage.predraw[user_id].push({ 'x': event.x, 'y': event.y }); |
|
} |