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

Shape tests #7323

Merged
merged 2 commits into from
Oct 22, 2024
Merged

Shape tests #7323

merged 2 commits into from
Oct 22, 2024

Conversation

davepagurek
Copy link
Contributor

This adds unit tests for the functionality within beginShape/endShape in 2D and WebGL mode so that we can use this as a checklist when refactoring the internals for shape drawing.

Some notes:

  • This doesn't test combinations of bezier + quadratic vertices within the same shape, since that isn't currently supported
  • There seems to be a bug where curveTightness is treated differently within WebGL and 2D modes. I'm leaving the test cases in for now, but we should expect one or the other to break in the future when we use a common implementation.

cc @GregStanton

@GregStanton
Copy link
Collaborator

Thanks @davepagurek! I just remembered that I previously made some informal test cases for a couple types of composite curves that aren't currently supported, when I was testing my proof of concept for the refactoring project. They cover mixing quadratic and cubic Béziers, as well as line segments and Catmull-Rom splines. I could add tests based on those later, if that sounds good.

@Qianqianye
Copy link
Contributor

Thanks @davepagurek @GregStanton. Is this ready to be merged?

@davepagurek davepagurek merged commit 54c31f9 into dev-2.0 Oct 22, 2024
2 checks passed
@davepagurek davepagurek deleted the shape-tests branch October 22, 2024 14:12
@GregStanton
Copy link
Collaborator

Should we add tests for POINTS, LINES, TRIANGLES, and QUADS?

It looks like TESS isn't covered here either, but I seem to remember a discussion about this feature no longer being necessary; it's currently used in the reference for beginShape() in the last two examples, but replacing beginShape(TESS) with beginShape() has no apparent effect. If it's no longer necessary, I'll make a reminder to remove it from the reference once we update it for p5.js 2.0.

@davepagurek
Copy link
Contributor Author

TESS is the explicit name for the default shape mode, so testing beginShape() with no arguments covers the same thing, so I think we're good there.

Adding POINTS, LINES, TRIANGLES, and QUADSwould be a good idea, I can add those!

@GregStanton
Copy link
Collaborator

Great! Thanks @davepagurek!

About TESS, it looks like that's the explicit name for the default shape kind in 3D mode, but as you may know, there is no explicit name for the default shape kind in 2D mode (it's just set to null). The reference doesn't specify the default in either case, and the explanation for TESS seems unclear. I'll address this as part of the refactoring, in accordance with #6679. We can discuss the details elsewhere, now that I know it's not relevant to this PR.

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.

3 participants