kotter
kotter copied to clipboard
Add an API for drawing a box
Something like
box(WIDTH, HEIGHT, x, y, "TEXT")
where
box(10, 10, 3, 5, "Hello")
would render (assume X's are spaces):
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXHelloXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
This would be useful in the robot example but also for something like, say, a "screensaver", like a text string that bounces around the console.
But this is low priority, and honestly may be a very niche case.
If we want overlaying text, e.g. a GAME OVER message drawing over the screen, this can be gnarly, because of needing to understand and update colors, e.g. above if the X's are yellow and Hello is red, we need to change the color back to yellow.
This probably means this feature is too custom and is kind of a deal breaker, unless we come up with some way to render text to an intermediate string and then we can merge those two together.
It's possible we could come up with an API similar to bordered which just got added today.
I don't think this has ever come up for me needing it, so I'm not going to add an API for it.
However, if you need it, you can delegate to justified:
justified(CENTER, minWidth = 10) {
repeat(4) { textLine() }
text("Hello")
repeat(5) { textLine() }
}