New feature: "path effects" (simplify, offset)#171
Merged
Merged
Conversation
0488f68 to
c22bd1b
Compare
This adds a new "path effects" (informally named) feature, providing the following two functions for transforming paths: * simplify: This function returns a new path set with any self-intersections removed from closed paths. An example would be a 5-point self-intersecting star; the outer 10-point path would be returned. Note that this differs from traditional polygon partitioning algorithms right now in that we don't return any of the sub-polygons that this might create (e.g., the pentagon or triangles in this instance), but we will split up any self-sealing polygons created (think a self-intersecting path creating two triangles). Additionally, this currently only accepts closed paths - open paths will be returned unchanged (although some things like co-linear points will be consolidated). * offset: This function returns a new path with all nodes offset by the supplied amount (negative values inset, positive values offset). The inside is determined by the direction of the path, particularly in the case of open paths, it is determined by the starting direction. While self-intersections will be processed, you will likely get undesirable results (hence why we give you simplify to help with this case).
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This adds a new "path effects" (informally named) feature, providing the following two functions for transforming paths:
simplify: This function returns a new path set with any self-intersections removed from closed paths. An example would be a 5-point self-intersecting star; the outer 10-point path would be returned. Note that this differs from traditional polygon partitioning algorithms right now in that we don't return any of the sub-polygons that this might create (e.g., the pentagon or triangles in this instance), but we will split up any self-sealing polygons created (think a self-intersecting path creating two triangles). Additionally, this currently only accepts closed paths - open paths will be returned unchanged (although some things like co-linear points will be consolidated).offset: This function returns a new path with all nodes offset by the supplied amount (negative values inset, positive values offset). The inside is determined by the direction of the path, particularly in the case of open paths, it is determined by the starting direction. While self-intersections will be processed, you will likely get undesirable results (hence why we give you simplify to help with this case).