Skip to content
Snippets Groups Projects
Commit 17dd327f authored by Moritz Langenstein's avatar Moritz Langenstein
Browse files

(ml5717) Fixed double dot on strokestart on iOS

parent dbd63245
No related branches found
No related tags found
No related merge requests found
......@@ -45,7 +45,6 @@ let room = null
const humanHasher = new humanhash()
const PREDICTED_POINT_COLOR = "#00000044"
const LAST_RECOGNIZED_PATH_ID = "LSP"
const pathIDsByPointerID = new Map()
......@@ -340,7 +339,7 @@ function drawIfRecognized(points, callback, notRecCallback) {
}
function clearRecognizedUpcoming() {
canvas.renderPath(LAST_RECOGNIZED_PATH_ID, [], [])
canvas.renderPath(canvas.LAST_RECOGNIZED_PATH_ID, [], [])
}
function drawRecognizedUpcoming(points) {
......@@ -348,7 +347,7 @@ function drawRecognizedUpcoming(points) {
points,
(recognizedPoints) =>
canvas.renderPath(
LAST_RECOGNIZED_PATH_ID,
canvas.LAST_RECOGNIZED_PATH_ID,
recognizedPoints.map((point) =>
faintPredictionPoint(point[0], point[1]),
),
......@@ -528,10 +527,12 @@ canvas.input.addEventListener("strokestart", ({ detail: e }) => {
const mousePos = getOffsets(e)
switch (currentTool) {
case toolSelection.Tools.PEN:
pathIDsByPointerID.set(
e.pointerId,
room.addPath(selectedColorAndRadiusPoint(...mousePos, pressure)),
)
if (!pathIDsByPointerID.has(e.pointerId)) {
pathIDsByPointerID.set(
e.pointerId,
room.addPath(selectedColorAndRadiusPoint(...mousePos, pressure)),
)
}
break
case toolSelection.Tools.ERASER:
eraseEverythingAtPosition(
......
......@@ -12,6 +12,8 @@ const SVG_URL = "http://www.w3.org/2000/svg"
import * as HTML from "./elements.js"
export const LAST_RECOGNIZED_PATH_ID = "LSP"
const curve = curveCatmullRom.alpha(1.0)
const smoothLine = line()
.x((d) => d[0])
......@@ -225,6 +227,18 @@ export const renderPath = (id, points, pathEraseIntervals) => {
)
let subpaths = applyErasureIntervals(points, pathEraseIntervals)
if (subpaths.length < 1 && id != LAST_RECOGNIZED_PATH_ID) {
const pathGroupElem = pathGroupElems.get(id)
if (pathGroupElem) {
pathGroupElems.delete(id)
HTML.canvas.removeChild(pathGroupElem)
}
return
}
subpaths = subpaths.map(smoothPath)
subpaths = subpaths.flatMap(splitOnPressures)
const subpathElems = subpaths.map((subpath) =>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment