How to create an partly transparent object,text .

The code below will help in creating transparent objects, texts and many more things in PyS60.

import appuifw
import graphics
import e32
 
def quit():
global running
running = False
 
def handle_redraw(rect):
canvas.clear(0×009900)
canvas.polygon(((0, 0), (bw, 0), (0, bh)), outline = 0xFFFF00, fill = 0xFFFF00)
 
textimgsize = (320, 20)
textimg = graphics.Image.new(textimgsize, "L")
textimg.clear(0×000000)
colorimg = graphics.Image.new(textimgsize)
colorimg.clear(0xFFFFFF)
 
textmsg = u"75% transparent text"
fontspec = (None, None, graphics.FONT_BOLD)
 
tleft, ttop, tright, tbottom = textimg.measure_text(textmsg, fontspec)[0]
tw = (tright - tleft)
th = (tbottom - ttop)
 
alpha = 0xC0C0C0
textimg.text((-tleft, -ttop), textmsg, alpha, fontspec)
canvas.blit(colorimg, target = ((bw - tw) / 2, (bh - th) / 2), mask = textimg)
 
canvas = appuifw.Canvas()
appuifw.app.body = canvas
bw, bh = canvas.size
appuifw.app.exit_key_handler = quit
 
running = True
while running:
handle_redraw(None)
e32.ao_yield()



Thank you for reading this post. You can now Leave A Comment (0) or Leave A Trackback.

Post Info

This entry was posted on Wednesday, July 2nd, 2008 and is filed under Blogroll.

You can follow any responses to this entry through the Comments Feed. You can Leave A Comment, or A Trackback.



Previous Post: Groups seek drilling halt near sage grouse habitat »
Next Post: Google wins source code ruling against Viacom »

Read More

Related Reading:



Leave a Reply

Note: Any comments are permitted only because the site owner is letting you post, and any comments will be removed for any reason at the absolute discretion of the site owner.

You must be logged in to post a comment.

edwan