- Docs
- Primitive
- How to draw a text
How to draw a text
Obtain a text primitive (with the configured default style):
OpenMap4u om4u = new OpenMap4u();
...
SetAreaOfInterestOrDrawOrWriteable myCanvas = om4u.getCanvas(4, 1);
...
Text myText = om4u.get(Text.class);
Set the text to draw:
myText.text("Hello world");
Set the position where to draw:
Draw it:
Write the result
myCanvas.write("myText.png");
Which results in the following output.
But wait you can do it much faster and simpler with the fluent builder pattern
myCanvas.draw(
om4u.get(Text.class).text("Hello world").center(0.5,0.25)
).write("myText.png");