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

Refactored the createGraphics function in rendering.js #6557

Merged

Conversation

Jaivignesh-afk
Copy link
Contributor

Resolves #6551

Changes:

Make some refactoring in createGraphics Function of rendering.js

Screenshots of the change:

PR Checklist

Copy link

welcome bot commented Nov 14, 2023

🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already. And be sure to add yourself to the list of contributors on the readme page!

*/
if (args[0] instanceof HTMLCanvasElement) {
args[0] = constants.P2D;
args[1] = args[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this is a bug: args[1] will also be constants.P2D because you are setting it equal to args[0] after resetting that to be constants.P2D.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely! I was thinking the same. Maybe using a temporary variable could do the trick? What do you reckon?

Copy link
Contributor

Choose a reason for hiding this comment

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

That would work, or alternatively just setting args[1] before args[0].

Made suggested changes
@Jaivignesh-afk
Copy link
Contributor Author

I have made the changes as you suggested @davepagurek

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 the updates! one last thing I noticed, and then I think we're good!

}
p5._validateParameters('createGraphics', arguments);
return new p5.Graphics(w, h, renderer, this, canvas);
p5._validateParameters('createGraphics', [w, h, ...args]);
Copy link
Contributor

Choose a reason for hiding this comment

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

One last thing, I think we might want to leave this one as arguments. I think the parameter validation method is intended to make sure what the user passes in matches the signatures in the docs. If something doesn't match, we want to give an error that corresponds to what the user has actually typed, not how we rearrange things, to avoid confusion.

@Jaivignesh-afk
Copy link
Contributor Author

Jaivignesh-afk commented Nov 17, 2023

I've changed it back to arguments as you suggested @davepagurek .

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 making the changes!

@davepagurek davepagurek merged commit bfb4c56 into processing:main Nov 21, 2023
2 checks passed
@davepagurek
Copy link
Contributor

@all-contributors please add @Jaivignesh-afk for code

Copy link
Contributor

@davepagurek

I've put up a pull request to add @Jaivignesh-afk! 🎉

@Jaivignesh-afk
Copy link
Contributor Author

I appreciate the feedback. It was a pleasure working on this contribution.

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.

suggestion for changes in createcanvas method's arguments
2 participants