diff --git a/src/app.js b/src/app.js index 1bc31f932f181cb552a47330d939298a48768d98..f1c3d7a24abde3181876f8db4a0bface960a0b2c 100644 --- a/src/app.js +++ b/src/app.js @@ -20,7 +20,7 @@ const tools = { const STROKECOLOUR = "blue" const STROKERADIUS = 2 -const ERASERRADIUS = STROKERADIUS * 5 +const ERASERRADIUS = STROKERADIUS * 8 function interpolatedCoordinate(start, end, length) { const dx = end[0] - start[0] @@ -79,7 +79,7 @@ const SVG = { }, } -let TEST_ERASE_INTERVAL = { 0: [0.4843534003374946, 0.7556465996625054] } +let TEST_ERASE_INTERVAL = {} function erasurePoints(pointA, pointB, start, fin) { if (start >= fin) return @@ -101,7 +101,6 @@ const addOrUpdatePathElem = (pathElems, id, points) => { if (pathElem == null) { pathElem = SVG.create.group() - console.log(pathElem) pathElem.setAttribute("stroke", STROKECOLOUR) pathElem.setAttribute("stroke-width", STROKERADIUS * 2) @@ -126,12 +125,10 @@ const addOrUpdatePathElem = (pathElems, id, points) => { let subPath = [] let toAdd = undefined - console.log("======") for (let i = 0; i < points.length; i++) { const point = points[i] if (toAdd) { subPath.push(toAdd) - console.log(toAdd) toAdd = undefined } @@ -166,7 +163,6 @@ const addOrUpdatePathElem = (pathElems, id, points) => { // Valid point inside a subpath subPath.push(point) - console.log(point) const eraseInterval = TEST_ERASE_INTERVAL[i] if (eraseInterval) { @@ -184,9 +180,7 @@ const addOrUpdatePathElem = (pathElems, id, points) => { ) subPath.push(start) - console.log(start) - console.log("ER", start, fin) const subpathElem = SVG.create.path() subpathElem.setAttribute("d", lineFn(subPath)) pathElem.appendChild(subpathElem) @@ -299,11 +293,11 @@ function handleRoomConnectionEstablished(room) { } else if (currentTool == tools.ERASER) { room.getPaths().forEach((points, pathID) => { const t = computeErasureIntervals(points, mousePos, ERASERRADIUS) - if (t[0]) TEST_ERASE_INTERVAL = t - // console.log(points) - console.log(TEST_ERASE_INTERVAL) + TEST_ERASE_INTERVAL = t room.dispatchEvent( - new CustomEvent("addOrUpdatePath", { detail: { id: 0, points } }), + new CustomEvent("addOrUpdatePath", { + detail: { id: pathID, points }, + }), ) points.forEach((point, i) => { if (getDistance(mousePos, point) <= ERASERRADIUS) {