Commit 0506044f authored by Christian Winter's avatar Christian Winter

contains-methods for lineendings now respect line thickness. also considered in selection methods

parent 154f6c58
Pipeline #4620992 passed with stage
in 1 minute and 1 second
......@@ -281,6 +281,9 @@ class Utilities {
}
static pointWithinCircle(p, center, radius) {
if (p instanceof LineEnding)
return Vector2.distance(p.position, center) <= radius + (p.line.thickness * 0.5);
return Vector2.distance(p, center) <= radius;
}
......
......@@ -10,8 +10,10 @@
if (pos instanceof Vector2)
return this.left <= pos.x && pos.x <= this.right &&
this.top <= pos.y && pos.y <= this.bottom;
else if (pos instanceof LineEnding)
return this.contains(pos.position);
else if (pos instanceof LineEnding) {
return this.left - pos.line.thickness <= pos.position.x && pos.position.x <= this.right + pos.line.thickness &&
this.top - pos.line.thickness <= pos.position.y && pos.position.y <= this.bottom + pos.line.thickness;
}
else if (pos instanceof Line) {
return this.containsLine(pos.start.position, pos.end.position, pos.thickness);
}
......
......@@ -144,7 +144,7 @@ class MouseHandler {
}
} else if (Preferences.selectVertices) {
for (let p of Utilities.linesToLineEndings(lines)) {
if (Utilities.pointWithinCircle(p.position, mousePosition, cursorRange))
if (Utilities.pointWithinCircle(p, mousePosition, cursorRange))
pointsToChangeSelection.push(p);
}
}
......
......@@ -20,15 +20,15 @@
}
} else if (Preferences.selectVertices) {
for (let line of File.currentLayer.lines) {
if (Utilities.pointWithinCircle(line.start.position, mousePosition, cursorRange))
if (Utilities.pointWithinCircle(line.start, mousePosition, cursorRange))
newSelPoints.push(line.start);
if (Utilities.pointWithinCircle(line.end.position, mousePosition, cursorRange))
if (Utilities.pointWithinCircle(line.end, mousePosition, cursorRange))
newSelPoints.push(line.end);
}
for (let line of Selection.data.partialLines) {
if (Utilities.pointWithinCircle(line.start.position, mousePosition, cursorRange))
if (Utilities.pointWithinCircle(line.start, mousePosition, cursorRange))
newSelPoints.push(line.start);
if (Utilities.pointWithinCircle(line.end.position, mousePosition, cursorRange))
if (Utilities.pointWithinCircle(line.end, mousePosition, cursorRange))
newSelPoints.push(line.end);
}
}
......@@ -48,16 +48,16 @@
}
else if (Preferences.selectVertices) {
for (let line of Selection.data.lines) {
if (Utilities.pointWithinCircle(line.start.position, mousePosition, cursorRange))
if (Utilities.pointWithinCircle(line.start, mousePosition, cursorRange))
newUnselPoints.push(line.start);
if (Utilities.pointWithinCircle(line.end.position, mousePosition, cursorRange))
if (Utilities.pointWithinCircle(line.end, mousePosition, cursorRange))
newUnselPoints.push(line.end);
}
for (let line of Selection.data.partialLines) {
if (Utilities.pointWithinCircle(line.start.position, mousePosition, cursorRange))
if (Utilities.pointWithinCircle(line.start, mousePosition, cursorRange))
newUnselPoints.push(line.start);
if (Utilities.pointWithinCircle(line.end.position, mousePosition, cursorRange))
if (Utilities.pointWithinCircle(line.end, mousePosition, cursorRange))
newUnselPoints.push(line.end);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment