473,320 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

[PIL] quake like multicoloured text

I'm wondering how I could render text with PIL in which different
parts of the text are different characters. This is for a game stats
script where names are written like:
^1Red ^2Green ^3Yellow, etc.
The problem is that I currently use text in the ImageDraw module but
the only way I can think of rendering text is by rendering each bit of
text in a separate colour.

Example:

draw.text((0,0),"Red", fill="red")
draw.text((30,0),"Green", fill="green")
draw.text((60,0),"Yellow", fill="green")

except that I'm not sure how much spacing there is between each
coloured bit of text(30px is assumed in the example)...Would there be
an alternate method of doing this?

Thanks =)
Sep 5 '08 #1
3 1129
Oops, I meant, "I'm wondering how I could render text with PIL in
which different
parts of the text are different *colours*."
Sep 5 '08 #2
En Fri, 05 Sep 2008 16:24:08 -0300, Durand <du*****@gmail.comescribió:
I'm wondering how I could render text with PIL in which different
parts of the text are different characters. This is for a game stats
script where names are written like:
^1Red ^2Green ^3Yellow, etc.
The problem is that I currently use text in the ImageDraw module but
the only way I can think of rendering text is by rendering each bit of
text in a separate colour.

Example:

draw.text((0,0),"Red", fill="red")
draw.text((30,0),"Green", fill="green")
draw.text((60,0),"Yellow", fill="green")

except that I'm not sure how much spacing there is between each
coloured bit of text(30px is assumed in the example)...Would there be
an alternate method of doing this?
You could use the draw.textsize method to measure how much space will take
each part...

--
Gabriel Genellina

Sep 5 '08 #3
On Sep 5, 10:32*pm, "Gabriel Genellina" <gagsl-...@yahoo.com.ar>
wrote:
En Fri, 05 Sep 2008 16:24:08 -0300, Durand <dura...@gmail.comescribió:


I'm wondering how I could render text with PIL in which different
parts of the text are different characters. This is for a game stats
script where names are written like:
^1Red ^2Green ^3Yellow, etc.
The problem is that I currently use text in the ImageDraw module but
the only way I can think of rendering text is by rendering each bit of
text in a separate colour.
Example:
draw.text((0,0),"Red", fill="red")
draw.text((30,0),"Green", fill="green")
draw.text((60,0),"Yellow", fill="green")
except that I'm not sure how much spacing there is between each
coloured bit of text(30px is assumed in the example)...Would there be
an alternate method of doing this?

You could use the draw.textsize method to measure how much space will take *
each part...

--
Gabriel Genellina
Thanks, I guess I should have done more research...
Sep 6 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Marek | last post by:
Hi, I have big problem when i try generate a PNG image with transparent background. When i open a source PNG file with tranasparent background everything is going well but not in IE. I know that...
0
by: jean-Baptiste Cazier | last post by:
Sæl ! I am trying to rotate some text and paste it into a larger PIL Image. ( cannot use PyFT for some reasons) However I have a problem of transparency and my new images in a box shape are...
4
by: Doug R | last post by:
I'm trying to create an anti-automation feature to prevent scripts from running reports on our website by requiring users to enter a code from an image (like Yahoo e-mail sign-up, or Network...
3
by: Steve Holden | last post by:
If nobody has a quick answer I'll go to the PIL list, but I'm having problems with PIL JPEG support on Windows, and figured someone on c.l.py might have solved this problem. I built the Cygwin...
1
by: Greg Lindstrom | last post by:
Hello- I'm running Python 2.3 on a windows box and would like to use PIL to superimpose text over an existing pgn image. I have no problem getting the text on the image but can not figure out how...
1
by: Daewon YOON | last post by:
Hi. I'm a newbie to this python world. PIL has 'text(position, string, options)' method in its ImageDraw module. Does this work with unicode or other 2byte encoded string? It seems not working...
6
by: Rancid Buttchutney | last post by:
I guess the subject says it all, really, and I know it's not a standard of the feature-set, but has anyone experimented with it? I'm writing an autocompleting INPUT element and would like it to...
1
by: Neil Toronto | last post by:
So I've recently had a stroke of insanity, deciding that what the open-source Quake III engine *really* needs is a good, healthy dose of Python. Here's the quick version: The Q3 engine is split...
0
by: Huuuze | last post by:
I could really use some help. Please take a look at the following image: http://img227.imageshack.us/img227/1346/grainynn3.png As you can see, the text in the image is fairly grainy. To get...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.