Open emilepainchaud opened 2 days ago
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!
Hi, Can I contribute on this issue??
Can you provide an example sketch of what you are hoping to do, so we can see the functionality ? thanks
Increasing access
I think that would make p5 more accessible for designers like me who are used to work with paragraphs containing multiple lines!
Most appropriate sub-area of p5.js?
Feature request details
Hi! I was trying to create a textbox width a rectangle that surrounds it. When my string is short, I can simply use the textWidth function to get the width, but my string is longer and has returns, it gets bit complicated to get both the width and the height of the text displayed on screen.
So I wrote this function to get the number of lines (so that I can use that number to multiply the height for one line of text by the number of lines so I have my nice rectangle surrounding my textbox) :
function getLineNb(txt, maxWidth) { let totalWidth = 0; let lineNb = 1; for (let i = 0; i < txt.length; i++) { totalWidth = totalWidth + textWidth(txt[i]); if (totalWidth >= maxWidth || txt[i] === "\n") { lineNb = lineNb + 1; totalWidth = textWidth(txt[i]); } } return lineNb; }
It doesn't output the right number when the maxWidth is very small though, so it should be reworked.
Maybe this could be a new feature inside P5!