From: Andrew J. <an...@la...> - 2002-01-06 14:56:55
|
<html> <head> </head> <body> Hello,<br> <br> I've added the requested text module, its still a little messy but I'm quite happy with the way it works. I've added a new directory to the cvs repositary so make sure you update with the -d switch as below.<br> <br> [andy@the_box pyzzle-cvs]$ cvs update -d<br> <br> So what are you waiting for get downloading, but dont forget to backup you code files. (-:<br> <br> Ok its the easyiest to use addition yet so lets get started:<br> <br> 1st off all the text stuff is contained in the following directory: pyzzle-cvs/data/text/<br> Because text is more data then code its included here and not in the main directory. Open that new textdata.py file in the text directory.<br> You will imeadiently notice there is a new text class similar to the ambient sound class. Its dead easy here is one:<br> <br> text2.text() # just defining text2<br> ...<br> text2.name = 'text2'<br> text2.string = 'You should have received a copy of the GNU General Public License\<br> along with Pyzzle; if not, write to the Free Software\<br> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA'<br> text2.fontFile = 'SNIDELY_.TTF'<br> text2.rect = (0, 0, 300, 300)<br> text2.colour = (200,0,0)<br> text2.size = 14<br> text2.justification = 1<br> <br> [textNo].name <- Give the text element a name, (Not in use yet)<br> <br> [textNo].string <- This is the text strings you want to display over the slide. Standard python string formatting or unicode formatting is used, see the python docs for more info about std. formatting.<br> <br> [textNo].fontFile <- Just the truetype font file you want the text to be displayed in. Note pyzzle only takes .ttf fonts and be carefull not to copy a copyrighted file. I dont want to get in trouble with adobe.(;<br> <br> [textNo].rect <- This is the rect* that will containing and position the font. As with most of pyzzles rects its position is relative to the topleft corner of the slide. There is no current checking if the rect is on th slide, so be careful with it. Note if a word of text is too long for the rect or if there is too much text for the rect then Pyzzle will exit. Also text is auto wrapped in the rect, hats off to David Clark of pygame for that code.<br> <br> [textNo].colour <- is just the RGB value for the text colour. Range 0-255.<br> <br> [textNo].size <- is just the size of the text. <br> <br> [textNo].justification <- is the justification for the text. Here are the different types:<br> 0 left-justified<br> 1 horizontally centered<br> 2 right-justified<br> <br> Ok this is all good, but how do you display the text? Well thats the simpilest part. for node.navtype there is a new element called 'text'<br> heres the example node view1_3 the view behind where you start in Gloom:<br> <br> view1_3.navtype = ['LandR', 'text'] <br> view1_3.file = ('castleroom1-3.jpg')<br> view1_3.navdata = view1_2,view1_4<br> view1_3.text = [text3]<br> <br> so view1_3.text = [text3] just tell pyzzle which text class to display. Simple. If you want to know how I change the text ramdomly then just has a look in slidechange.py.<br> <br> Ok that it. Currently there are no realtime functions for text, like the image ones. I dont know how useful they would be but I anyone wants them it would be pretty simple to write them. Also note all the text is anti-aliased pygame anti-aliasing is really good, but not quite upto pro graphics packages.<br> <br> Other news for Pyzzle is that pygame OSX support is rocking allong, which is exelent news for Pyzzle and Pygame. So if anyone knows anyone with a OSX box have a chat to them about Pyzzle. When pygames osx support becomes official I will write a more official email requesting people to test pyzzle with OSX. So get them interested in the mean time.<br> <br> Have fun with the new text class.<br> Andy<br> <br> <br> * For those who do not know what a rect is then its just pygames way of representating a rectange container. It works like:<br> somerect = (<i>leftPos</i> , <i>topPos</i> , <i>width</i> , <i>height</i> )<br> Note for Pyzzle <i>leftPos</i> and <i>topPos</i> are usually relative to the topleft corner of the slide.<br> Easy. (-;<br> </body> </html> |