Skip to content
Snippets Groups Projects
Commit 3f9afe67 authored by Yuriy Maksymets's avatar Yuriy Maksymets
Browse files

Using correct path ID

parent fc443448
No related branches found
No related tags found
No related merge requests found
......@@ -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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment