★ wanayoo — archive 1999 https://github.com/libtcod/python-tcod/issues/95Nouvelle recherche | Portail wanayoo
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

Wrong behavior for tcod.console.Console.draw_frame with title and colors #95

Open
Earl7Fx3 opened this issue Jun 17, 2020 · 3 comments
Open
Assignees

Comments

@Earl7Fx3
Copy link

@Earl7Fx3 Earl7Fx3 commented Jun 17, 2020

version 11.13.5 but it's been around for a while.

This call will produce the following (expected) result:
con.draw_frame(0, 0, 11, 5, 'test3')
image

If I want to modify the border color (and the title color), according to the doc:

fg and bg are the foreground text color and background tile color respectfully. This is a 3-item tuple with (r, g, b) color values from 0 to 255. These parameters can also be set to None to leave the colors unchanged.

but this call produces this:
con.draw_frame(0, 0, 11, 5, 'test3', fg=tcod.grey)
image

so if I want to get the title visible again, I either need to write above it or do the following call:
con.draw_frame(0, 0, 11, 5, 'test3', fg=tcod.grey, bg=tcod.black)
image
which is not what I wanted, though, and neither what the doc describes.

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.

@HexDecimal
Copy link
Collaborator

@HexDecimal HexDecimal commented Jun 17, 2020

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)
@Earl7Fx3
Copy link
Author

@Earl7Fx3 Earl7Fx3 commented Jun 17, 2020

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:
image
image

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.

@HexDecimal HexDecimal self-assigned this Jun 17, 2020
@HexDecimal
Copy link
Collaborator

@HexDecimal HexDecimal commented Jun 17, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.