Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

227
Views
How to get bounding shape for wrapped text in p5.js

I'm creating a p5 project in which I create text from a string, wrap it using the 'WORD' option and add it to the canvas. As an example:

let font;

function preload() {
  font = loadFont('SomeFont.otf');
}

function setup() {
  createCanvas(400, 400);
  background(220);
  enteredText = 'This is an exmple of a long text that should split';
  textWrap(WORD);
  textSize(30);
  textAlign(CENTER, CENTER);
  textFont(font);
  textLeading(0.83 * 30);
  rectMode(CENTER);
  fill(0);
  noStroke();
  
  text(enteredText, width / 2, height / 2, 20 , 20);
}

I'd like to get a bounding shape for the text, in order to add some images on the frame. How can I get this shape? I thought about using textBounds(), but I also don't have the multiline string since textWrap() is doing it for me. Any ideas? Re-writing textWrap() by myself feels like an overkill since there are so many properties for it.

Thanks!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!