-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add Paint Selection feature to SelectionState #162
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
70bea12
feat: add selection paint mode
MinCrohn e084156
fix test
MinCrohn 2014a9c
fix
MinCrohn 08d2982
fix docs
MinCrohn 161c973
fix
MinCrohn 317070f
fix
MinCrohn ec22287
delete duplicate
MinCrohn ba6c653
refactor
MinCrohn 4aa4cd3
fix: ensure paint selection order by sorting objects by proximity to …
MinCrohn 9fe6b4b
fix
MinCrohn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { intersectPoint } from './intersect-point'; | ||
|
|
||
| /** | ||
| * Calculates the smallest t (0 to 1) along the segment (p1, p2) where it first enters the object. | ||
| * Returns 0 if p1 is already inside the object. | ||
| * Returns null if the segment does not intersect the object. | ||
| * | ||
| * @param {PIXI.DisplayObject} obj - The object to check. | ||
| * @param {PIXI.Point} p1 - The start point of the segment. | ||
| * @param {PIXI.Point} p2 - The end point of the segment. | ||
| * @param {PIXI.Point[]} corners - The corners of the object in the same coordinate space as p1 and p2. | ||
| * @returns {number|null} The minimum t value (0 to 1) or null. | ||
| */ | ||
| export const getSegmentEntryT = (obj, p1, p2, corners) => { | ||
| if (intersectPoint(obj, p1)) { | ||
| return 0; | ||
| } | ||
|
|
||
| let minT = 1.1; | ||
|
|
||
| for (let i = 0; i < corners.length; i++) { | ||
| const v1 = corners[i]; | ||
| const v2 = corners[(i + 1) % corners.length]; | ||
|
|
||
| const t = intersectSegments(p1.x, p1.y, p2.x, p2.y, v1.x, v1.y, v2.x, v2.y); | ||
| if (t !== null && t < minT) { | ||
| minT = t; | ||
| } | ||
| } | ||
|
|
||
| return minT > 1 ? null : minT; | ||
| }; | ||
|
|
||
| /** | ||
| * Calculates the intersection t of two line segments. | ||
| * | ||
| * @private | ||
| */ | ||
| function intersectSegments(x1, y1, x2, y2, x3, y3, x4, y4) { | ||
| const dx12 = x2 - x1; | ||
| const dy12 = y2 - y1; | ||
| const dx34 = x4 - x3; | ||
| const dy34 = y4 - y3; | ||
| const denominator = dy34 * dx12 - dx34 * dy12; | ||
|
|
||
| if (denominator === 0) { | ||
| return null; | ||
| } | ||
|
|
||
| const dx13 = x1 - x3; | ||
| const dy13 = y1 - y3; | ||
| const t = (dx34 * dy13 - dy34 * dx13) / denominator; | ||
| const u = (dx12 * dy13 - dy12 * dx13) / denominator; | ||
|
|
||
| if (t >= 0 && t <= 1 && u >= 0 && u <= 1) { | ||
| return t; | ||
| } | ||
| return null; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.