kotter icon indicating copy to clipboard operation
kotter copied to clipboard

Add an API for drawing a box

Open bitspittle opened this issue 4 years ago • 2 comments

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.

bitspittle avatar Aug 28 '21 05:08 bitspittle

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.

bitspittle avatar Sep 03 '21 05:09 bitspittle

It's possible we could come up with an API similar to bordered which just got added today.

bitspittle avatar Dec 27 '21 21:12 bitspittle

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() }
}

bitspittle avatar Oct 29 '22 17:10 bitspittle