Closed Earl7Fx3 closed 2 years ago
Thanks for going through the effort to post this. Unfortunately the docs were already fixed, at least as far as being more clear on the behavior of colors.
This should perform what you originally wanted to do:
con.draw_frame(0, 0, 11, 5, fg=tcod.grey)
con.print_box(0, 0, 11, 1, ' test3 ', fg=tcod.grey, alignment=tcod.CENTER)
Thank you, it is indeed a work-around but I humbly believe the inconsistency with the default call is wrong, albeit not a bug: If I want a white border with black background, like the 1st picture provided, it would make sense that
con.canvas.draw_frame(0, 0, 11, 5, 'test3')
con.canvas.draw_frame(0, 0, 11, 5, 'test3', fg=tcod.white, bg=tcod.black)
produce the same results, but instead we get this:
It feels wrong that the default behavior gives same color for the text than the border, but if you specify the border color it is not. Furthermore, if you specify only fg, then both the text color and the background text color are the same color.
I don't see it as a workaround, I see it as the correct way to draw frame titles. I don't want all libtcod games to have this single style of frame banner enforced by draw_frame.
To me, it's the function limiting what a title banner can look like that's wrong, and if draw_frame didn't already take the title parameter then I'd feel no need to add it.
The technical problem of draw_frame is that it draws the frame with one set of colors then draws the title with a swapped set, which absolutely breaks if either of the colors are None. It can be fixed by changing from one forced style to another or by disallowing None for the colors when a title is given.
Closing since the confusing syntax has been deprecated in the current versions, and the code examples demonstrate the better way to render title text.
version 11.13.5 but it's been around for a while.
This call will produce the following (expected) result:![image](https://user-images.githubusercontent.com/67057359/84900289-2af74b00-b0aa-11ea-91b6-3d877a304c65.png)
con.draw_frame(0, 0, 11, 5, 'test3')
If I want to modify the border color (and the title color), according to the doc:
but this call produces this:![image](https://user-images.githubusercontent.com/67057359/84900485-7c073f00-b0aa-11ea-9d2b-20022a33ad48.png)
con.draw_frame(0, 0, 11, 5, 'test3', fg=tcod.grey)
so if I want to get the title visible again, I either need to write above it or do the following call:
which is not what I wanted, though, and neither what the doc describes.
con.draw_frame(0, 0, 11, 5, 'test3', fg=tcod.grey, bg=tcod.black)
to sum up, I believe the color of the border, which is given by fg, shouldn't be the color of the background for the title area, that should remain given by bg.