-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Refactored the createGraphics function in rendering.js #6557
Conversation
🎉 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]; |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
I have made the changes as you suggested @davepagurek |
There was a problem hiding this 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!
src/core/rendering.js
Outdated
} | ||
p5._validateParameters('createGraphics', arguments); | ||
return new p5.Graphics(w, h, renderer, this, canvas); | ||
p5._validateParameters('createGraphics', [w, h, ...args]); |
There was a problem hiding this comment.
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.
I've changed it back to |
There was a problem hiding this 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!
@all-contributors please add @Jaivignesh-afk for code |
I've put up a pull request to add @Jaivignesh-afk! 🎉 |
I appreciate the feedback. It was a pleasure working on this contribution. |
Resolves #6551
Changes:
Make some refactoring in createGraphics Function of rendering.js
Screenshots of the change:
PR Checklist
npm run lint
passes