Skip to content
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

Add Area and Centroid nodes #1749

Merged

Conversation

elbertronnie
Copy link
Collaborator

@elbertronnie elbertronnie commented May 9, 2024

  • Create Area and Centroid nodes which can provide the area and centroid of VectorData respectively.
  • Create new function perimeter_centroid for Bezier and Subpath that calculates the line integral of position.
  • Create new function is_linear which check if the bezier curve is equivalent to a line. Used in the calculation of intersection of two bezier curves where initially a line-like cubic bezier would give the wrong area.

@0HyperCube 0HyperCube force-pushed the create-area-and-centroid-nodes branch from 3e4f70c to c2cb287 Compare May 9, 2024 20:34
@elbertronnie elbertronnie marked this pull request as draft May 9, 2024 21:46
@elbertronnie elbertronnie marked this pull request as ready for review May 13, 2024 20:40
@elbertronnie elbertronnie force-pushed the create-area-and-centroid-nodes branch from 9f2cfc4 to 2671107 Compare May 13, 2024 20:50
@Keavon Keavon force-pushed the create-area-and-centroid-nodes branch 2 times, most recently from ab7adc3 to 67467f0 Compare May 22, 2024 08:50
@Keavon Keavon changed the title Create Area and Centroid nodes Add Area and Centroid nodes May 22, 2024
@Keavon Keavon force-pushed the create-area-and-centroid-nodes branch from 67467f0 to 64b6bb2 Compare May 22, 2024 09:39
@Keavon
Copy link
Member

Keavon commented May 22, 2024

!build

@@ -218,6 +218,20 @@ impl Bezier {

self.get_points().all(|point| point.abs_diff_eq(start, MAX_ABSOLUTE_DIFFERENCE))
}

// TODO: What about the case when a handle extends beyond the start or end point? Is that considered "equivalent to a line"?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this TODO comment. Can you please resolve this by mentioning the appropriate thing here to document this edge case? Thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The is_linear will function will declare it as a line and that is what we want. The problem is in the place is_linear will be used. The start and end points will be chosen incorrectly. Instead it should use the handle point if it is further than start or end points.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this was originally put because the pen tool uses cubic beziers for straight lines. The handle are exactly at the same position of start and end. Since its actual use-case was covered. I did not think any further. If we want it to work for all cases then I will require some time think about it.

Copy link

📦 Build Complete for 64b6bb2
https://40a4d8e3.graphite.pages.dev

@Keavon
Copy link
Member

Keavon commented May 22, 2024

!build

Copy link

📦 Build Complete for 4fc20b2
https://11d51019.graphite.pages.dev

@Keavon
Copy link
Member

Keavon commented May 22, 2024

Cool!

capture_29_.mp4

@Keavon Keavon merged commit 5a1c171 into GraphiteEditor:master May 22, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants