Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

228
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda