PFont f;
void setup() {
size (550, 200);
int fontSize = 40;// change here and averything goes along...
f = createFont("arial", fontSize);
textFont(f);
String hi = "Hi, there. How*s every thing?";
//arbitrary
float xPos = 20;
float yPos = height/2;
text(hi, xPos, yPos);
// width
float textWid = textWidth(hi);
//lower y position including descent of text
float lower = yPos + textDescent();
//upper calculated from lowewr point
float upper = lower - fontSize;
// your own box : )
stroke(150);
line(xPos, lower, xPos + textWid, lower);
line(xPos, upper, xPos + textWid, upper );
line(xPos, upper, xPos, lower );
line(xPos + textWid, upper, xPos + textWid, lower );
// not considering descent
stroke(255, 0, 0, 180);
line(xPos, yPos, xPos + textWid, yPos);
}
void setup() {
size (550, 200);
int fontSize = 40;// change here and averything goes along...
f = createFont("arial", fontSize);
textFont(f);
String hi = "Hi, there. How*s every thing?";
//arbitrary
float xPos = 20;
float yPos = height/2;
text(hi, xPos, yPos);
// width
float textWid = textWidth(hi);
//lower y position including descent of text
float lower = yPos + textDescent();
//upper calculated from lowewr point
float upper = lower - fontSize;
// your own box : )
stroke(150);
line(xPos, lower, xPos + textWid, lower);
line(xPos, upper, xPos + textWid, upper );
line(xPos, upper, xPos, lower );
line(xPos + textWid, upper, xPos + textWid, lower );
// not considering descent
stroke(255, 0, 0, 180);
line(xPos, yPos, xPos + textWid, yPos);
}