0 votes
asked in ESPaper by (140 points)
Is it posible with the graphic lib of the ESPaper to place text allign?

As an example : allign_text(text,x,y,alligment)

text = my text string

x,y = position on the screen

alligment = (Left,Centre,Right)

Kindley regards,

Jan Kromhout

Hellevoetsluis-NL

1 Answer

0 votes
answered by (2.7k points)
You could create your own function to do that:

void AlignText(String text, int x, int y, String alignment){
  alignment.toLowercase();
  if (alignment  == “left”) gfx.setTextAlignment(TEXT_ALIGN_LEFT);
  if (alignment  == “center”) gfx.setTextAlignment(TEXT_ALIGN_CENTER);
  if (alignment  == “right”) gfx.setTextAlignment(TEXT_ALIGN_RIGHT);
  gfx.drawString(x,y,text);
  gfx.setTextAlignment(TEXT_ALIGN_LEFT); // back to default
}

Welcome to ThingPulse Q&A, where you can ask questions and receive answers from other members of the community.

https://thingpulse.com

...