I
Iacopo.Marmo
Hi! I need to manipulate multicolor strings, i.e. strings with a color
associated with each letter.
Any suggestions?
associated with each letter.
Any suggestions?
Hi! I need to manipulate multicolor strings, i.e. strings with a color
associated with each letter.
Any suggestions?
Hi! I need to manipulate multicolor strings, i.e. strings with a color
associated with each letter.
Any suggestions?
Diez said:Hi! I need to manipulate multicolor strings, i.e. strings with a color
associated with each letter.
Any suggestions?
There is no support for multi-color strings as such in pygame. If you
use a fixed-width font, things are easy. Just create the strings one
after another using spaces as prefix. E.g.
back = (0,0,0)
font = pygame.font.Font(font_fn, size)
images = []
for i, c in enumerate("colored string"):
s = " " * i + c
color = color_for_index(i)
s_image = font.render(s, True, color, back)
images.append(s_image)
character and each color (cached or not, however you like it), and just
blit these one after another, offsetting them with the character width.
Diez
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.