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

Remove old overloads for bezierVertex() and quadraticVertex() #7600

Merged
merged 2 commits into from
Mar 5, 2025

Conversation

davepagurek
Copy link
Contributor

Changes

Based on discussion in processing/p5.js-compatibility#1 and elsewhere, this removes the overloads for 1.x bezier functions, leaving just the 2.0 ones. The overloads are handled in the shape compatibility addon instead.

PR Checklist

@davepagurek
Copy link
Contributor Author

@limzykenneth let me know if we're good to merge this!

@@ -663,20 +663,7 @@ function vertex(p5, fn){
* @param {Number} z4 z-coordinate of the anchor point.
*/
fn.bezierVertex = function(...args) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for doing this Dave! This part looks good. I'll make a separate PR to move this over to custom_shapes.js, and I'll update the inline reference when I do.

@@ -194,8 +194,13 @@ visualSuite('Shape drawing', function() {
setup(p5);
p5.beginShape();
p5.vertex(10, 10);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we not already have tests for the new API? If we do, then maybe this whole test could be removed, rather than converting it to the new API? The same goes for the other tests that were updated.

If we do keep this test, could we replace p5.vertex(10, 10); with p5.bezierVertex(10, 10), to reflect our decision about the explicit first-vertex issue? Right now, I think the code should work the same either way because of how we implemented these features, but I guess it'd be good to align the tests with the API spec in case the implementation changes. (I've been keeping the main post at the top of #6766 up to date, including with our decision to move the legacy API into a compatibility add-on. So the description there can serve as an informal spec, and I'll base the new documentation on it.)

Copy link
Member

Choose a reason for hiding this comment

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

These are visual tests, ie. essentially integration test so it is separate from unit test, so this should stay around as I don't see another visual test testing bezier curves. It is fine to replace the first vertex with bezierVertex.

@@ -204,9 +209,13 @@ visualSuite('Shape drawing', function() {
setup(p5);
p5.beginShape();
p5.vertex(10, 10);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same question as on line 196. If we can't remove the whole test, could we replace it with the following?

p5.beginShape();

p5.bezierOrder(2);
p5.bezierVertex(10, 10);
p5.bezierVertex(10, 10);
p5.bezierVertex(15, 40);

p5.bezierVertex(40, 35);
p5.bezierVertex(25, 15);

p5.bezierVertex(15, 25);
p5.bezierVertex(10, 10);

p5.endShape();

(By the way, I'm guessing the reason for doubling up the vertices at (10, 10) is to make sure we get a line segment in that case.)

@@ -224,10 +224,9 @@ suite('p5.Geometry', function() {

myp5.beginShape();
myp5.vertex(-20, -50);
myp5.quadraticVertex(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same issue here as on lines 196 and 211. Could replace with the following:

myp5.beginShape();
myp5.bezierOrder(2);
myp5.bezierVertex(-20, -50);
myp5.bezierVertex(-40, -70);
myp5.bezierVertex(0, -60);
myp5.endShape();

@limzykenneth
Copy link
Member

@davepagurek If you want to make the vertex to bezierVertex change mentioned if it doesn't change the visual output, but we can merge as long as no test failed.

@davepagurek davepagurek merged commit d820651 into dev-2.0 Mar 5, 2025
2 checks passed
@davepagurek davepagurek deleted the remove-old-shape-overloads branch March 5, 2025 18:30
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