Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

231
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda