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 »
- Would-be Japanese space tourist wants $21M back
- NASA scales back flagship Mars mission
- Bulgarian archaeologists unearth ancient chariot
- Witnesses: Large meteor streaks across Canada sky
- Solar panels on graves give power to Spanish town
- Fuel from food? The feast is over
- Fabulous flippers: Dolphins have quite the kick
- Whales rescued from Australian beach join pod
- Siberian quake triggers false US seismic reports
- Pirates sign Indian _ not Cleveland _ pitchers

