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

Fix Load Function to Accept a callback without triggering a warning #7551

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Jatin24062005
Copy link

@Jatin24062005 Jatin24062005 commented Feb 15, 2025

Resolves #7541

Changes:
Allow loadFont() to accept a callback without triggering a warning by adding up the condition statement. which checks the load function arguments and the function

PR Checklist

Copy link

welcome bot commented Feb 15, 2025

🎉 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!

@davepagurek
Copy link
Contributor

Hey @Jatin24062005, rather than making a special case for fonts here, are we able to update the doc comments for loadFont to more accurately reflect the different possible overloads?

@Jatin24062005
Copy link
Author

Hey @davepagurek ! I saw that @limzykenneth mentioned some contributors are already working on the documentation. Should I still proceed with updating the doc comments for loadFont(), or would it be better to coordinate with them to avoid duplicate efforts?

@davepagurek
Copy link
Contributor

If you're still up for working on it, we can just make sure @GregStanton and @perminder-17 know you're working on this one!

@Jatin24062005
Copy link
Author

@davepagurek I believe @GregStanton and @perminder-17 might be a better fit for handling the documentation updates, as they have more experience in this area. I haven’t worked much with graphics, which makes me a bit less confident in making the necessary changes.
However, if you can guide me on the key updates needed, I’d be happy to give it a try!

@GregStanton
Copy link
Collaborator

Hi @Jatin24062005! Thanks so much for your help!

@davepagurek: Do you think you'd be able to offer @Jatin24062005 some help here? Otherwise, just ping me, and I'll do my best to help. I'll just need to familiarize myself with this feature a bit more before I do.

@davepagurek
Copy link
Contributor

Hey, sorry for the delay! I think what we need to do here is add a doc comment above loadFont, which is defined here:

p5.prototype.loadFont = async function (...args/*path, name, onSuccess, onError, descriptors*/) {

A similar example for loadImage is here:

* @method loadImage
* @param {String|Request} path path of the image to be loaded or base64 encoded image.
* @param {function(p5.Image)} [successCallback] function called with
* <a href="#/p5.Image">p5.Image</a> once it
* loads.
* @param {function(Event)} [failureCallback] function called with event
* error if the image fails to load.
* @return {Promise<p5.Image>} the <a href="#/p5.Image">p5.Image</a> object.

The square brackets around a parameter name indicates that it's optional.

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