Open felipemanga opened 1 year ago
TIC-80 (and maybe pico-8?) just return the text width after a print (text
in MicoJS) command. So in general if you need to work with a calculated width, you just print somewhere offscreen and then do your business. A little funky, and not sure how well that would jive with how you do your render queue... But it does have the added benefit of sequential "marquee" style outputs:
let x = 50;
x += text("Hello ", x, y);
setPen(emphasisColor);
text("WORLD!", x, y);
This example contrived, but especially in UI that shows counters I find myself wanting this kind of functionality more often than not.
Just some food for thought :)
Hmmm, that sounds useful for printing a long line with various text calls, but annoying for something like centralizing text or putting text on the right side of the screen. Maybe we should we have both.
const width = getWidth("string"); // gets width with current font