-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(Geometry): containsPoint
- BREAKING Canvas#_checkTarget
#9372
Conversation
Build Stats
|
restore restore restore Update Intersection.ts fix Create Intersection.spec.ts isPointInPolygon Update Intersection.ts Update Intersection.ts Update Intersection.ts Update Intersection.ts update CHANGELOG.md Update CHANGELOG.md
c30da23
to
6b868df
Compare
Update Intersection.ts Update Intersection.ts Update Intersection.ts Update Intersection.ts
2258ce0
to
5e90f11
Compare
Update Object.spec.ts
5e90f11
to
6bc9aec
Compare
containsPoint
containsPoint
- BREAKING Canvas#_checkTarget
Excuse me for interrupting. Is this case overwritten? const rect = new Rect({ left: 0, top: 0, width: 100, height: 100 });
const g = new Group([rect], { left: 0, top: 0 });
const g2 = new Group([g], { left: 10, top 10 });
canvas.add(g2);
const p = new Point(5, 5);
const flag = g.containsPoint(p);
console.log(flag); Or do I need to manually remove the child elements from the group and then evaluate, and once evaluated, restore them, like this? const rect = new Rect({ left: 0, top: 0, width: 100, height: 100 });
const g = new Group([rect], { left: 0, top: 0 });
const g2 = new Group([g], { left: 10, top 10 });
canvas.add(g2);
const p = new Point(5, 5);
+ const gg = g.group;
+ gg.remove(g);
const flag = g.containsPoint(p);
+ gg.add(g);
console.log(flag); // Is this the correct way to achieve the desired result? |
// Do not check for currently grouped objects, since we check the parent group itself. | ||
// until we call this function specifically to search inside the activeGroup | ||
while (i--) { | ||
const objToCheck = objects[i]; | ||
const pointerToUse = objToCheck.group | ||
? this._normalizePointer(objToCheck.group, pointer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_normalizePointer can go away now. It was used only for this and was explicitly private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i removed it
src/canvas/SelectableCanvas.ts
Outdated
// http://idav.ucdavis.edu/~okreylos/TAship/Spring2000/PointInPolygon.html | ||
obj.containsPoint(pointer) | ||
obj.containsPoint( | ||
sendPointToPlane(pointer, undefined, this.viewportTransform), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use this.restorePointerVpt(pointer) here?
We are taking the pointer in html coordinates and we are transitioning it to scene coordinates correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change and looking at possibly adding tests is the only thing i need to merge this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I deliberately removed this usage
You removed restoreVpt so why leave this?
It is removed in the getPointer renaming pr, is it not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is yet another method to explain what it does with 1 or 2 usages abd as confusung as getPointer
i ll add specific tests for the new functionality in a following PR. |
Motivation
containsPoint
is not user freinly and that is a shame.It accepts points in different planes depending on use cases and is to me at least unintuitive.
This is actually a part of #8767 - Since you have freezed it I have decided to extract this important part immediately.
Description
First merge #9333
Changes
BREAKING
containsPoint
signaturecontainsPoint(point, lines, absolute, calculate)
=>containsPoint(point, absolute, calculate)
_checkTarget
signature_checkTarget(pointer, target, globalPointer)
=>_checkTarget(target, globalPointer = pointerFromViewport)
Gist
I believe it is now possible to remove lineCoords
In Action