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

canvas doesn't load, no error thrown when invalid parameter passed to textWrap() #6997

Closed
3 tasks done
rbstrachan opened this issue Apr 29, 2024 · 3 comments · Fixed by #7009
Closed
3 tasks done

canvas doesn't load, no error thrown when invalid parameter passed to textWrap() #6997

rbstrachan opened this issue Apr 29, 2024 · 3 comments · Fixed by #7009

Comments

@rbstrachan
Copy link

rbstrachan commented Apr 29, 2024

Most appropriate sub-area of p5.js?

  • Core/Environment/Rendering
  • Typography
  • Friendly errors

p5.js version

1.9.2

Web browser and version

Firefox 125.0.2

Operating system

Linux Ubuntu 22.04 LTS

Steps to reproduce this

Steps

  1. Create a new project.
  2. Pass an invalid parameter, such as a number or string, to textWrap() in setup().

Snippet

function setup() {
  createCanvas(400, 400);
  textWrap(50);
}

Notes

When I first tried to use textWrap(), I wrongly assumed it took the maximum width, in pixels, of the text before wrapping occurred, so I did something like textWrap(width * 2 / 3);. The canvas disappeared and no error was given. I believe I've seen this behavior before with other methods but I can't remember which ones.

@rbstrachan rbstrachan added the Bug label Apr 29, 2024
Copy link

welcome bot commented Apr 29, 2024

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, please make sure to fill out the inputs in the issue forms. Thank you!

@rbstrachan
Copy link
Author

rbstrachan commented Apr 29, 2024

It seems that the textWrap() function (src/typography/attributes.js#L541) does do a simple if then check to throw an error, but doesn't use p5._validateParameters().

@limzykenneth
Copy link
Member

@rbstrachan Issue is as you identified and using p5._validateParameters() does solve the issue as intended. However, there are some unit test related issue that was left uncaught for awhile and I need to fix that before fixing this. Will try to do so today. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants