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

Do away with strokeIndices and construct Geometry directly with edges #6121

Merged
merged 3 commits into from
Apr 29, 2023
Merged

Do away with strokeIndices and construct Geometry directly with edges #6121

merged 3 commits into from
Apr 29, 2023

Conversation

inaridarkfox4231
Copy link
Contributor

Currently, strokeIndices is used to define edges regardless of faces when composing geometry.

However, the way to configure edges using it is to copy the contents of strokeIndices to edges as they are in _makeTriangleEdges(), which is a wasteful process.

So, I wanted to rewrite the processing method so that edge information is stored in edges from the beginning.
StrokeIndices is not prepared even at initialization, and in that sense it is not a very natural process.

Also, when creating APIs in the future, I thought it would cause confusion if there was a way of processing that didn't matter which way, so I wanted to unify it.

In addition to that, the specification of model() was changed so that edges are constructed from faces only when edges are not provided in the model function. This allows p5.Geometry to construct a geometry without losing its contents for edges, even if it has no faces and only edges, or constructs its own edges.

Resolves #6120

Changes:

  • replace "strokeIndices" with "edges" in arc, box, triangle, rect and avoid calling _makeTriangleEdges()
  • In _makeTriangleEdges(), omit the processing performed for strokeIndices
  • In model(), construct edges from faces only when edges.length is 0.

Screenshots of the change:

Demo: patch_model_2

I tried it, but the box, triangle, arc, and rect whose specifications were changed here were all drawn as usual.

gottani

PR Checklist

Removed strokeIndices term from _makeTriangleEdges()
Since we've decided not to use strokeIndices, we won't do anything about it. This content is simply a process of replacing strokeIndices with edges, so you can just put it in edges from the beginning, and it is practically unnecessary.
Since strokeIndices has many unnatural points such as not being prepared at initialization, we will replace it with edges.
Also, I decided not to call _makeTriangleEdges() when creating custom edges.
The edge configuration of model() is only when there is no edge.
This makes it easier to compose when the p5.Geometry consists only of edges.
Copy link
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

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

Thanks for implementing this, it makes geometry code an extra bit cleaner!

@davepagurek davepagurek merged commit 35ec2c1 into processing:main Apr 29, 2023
@inaridarkfox4231
Copy link
Contributor Author

thanks for merge! ('ω')

@inaridarkfox4231 inaridarkfox4231 deleted the eliminate_strokeindices branch April 29, 2023 14:21
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.

Avoid using strokeIndices and use edges directly, when creating the geometry
2 participants