Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an API for drawing a box #27

Closed
bitspittle opened this issue Aug 28, 2021 · 3 comments
Closed

Add an API for drawing a box #27

bitspittle opened this issue Aug 28, 2021 · 3 comments
Labels
enhancement New feature / functionality maybe Not sure if we're going to do this issue or not

Comments

@bitspittle
Copy link
Contributor

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 bitspittle added enhancement New feature / functionality maybe Not sure if we're going to do this issue or not labels Aug 28, 2021
@bitspittle bitspittle changed the title (Maybe) Add an API for drawing a box Add an API for drawing a box Sep 2, 2021
@bitspittle
Copy link
Contributor Author

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
Copy link
Contributor Author

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

@bitspittle
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature / functionality maybe Not sure if we're going to do this issue or not
Projects
None yet
Development

No branches or pull requests

1 participant