"""Programa que saca por pantalla la curva del dragon. Los dibujos resultantes se grabaran en e:\images\snap. Si no tienes esa carpeta creala o el programa no funcionara. Programado Por Marcos Ochoa Diez""" import appuifw import e32 import graphics from random import randint from key_codes import * def _raw_input( txt ): return appuifw.query( unicode( txt ), "text" ) appuifw.app.title=u"^MvIiIaX^ Curva Dragon" appuifw.note(u"Bienvenid@ Al Programa ^MvIiIaX^ Curva Dragon Programado Por Marcos Ochoa Diez.", "info" ) coloresa=appuifw.query(u'Colores Aleatorios 1-SI 2-NO: ', 'text',u'2') kkk=14 if int(coloresa)==1: cuanto=appuifw.query(u'Cuantos Graficos Sacamos Y Grabamos: ', 'text',u'1') fondo=appuifw.query(u'Fondo Blanco 1 o Fondo Aleatorio 2: ', 'text',u'1') lulu=1 def dragon(level, turn): global x, y, dx, dy, p if level == 0: if int(coloresa)==2: canvas.line((x,y,x+dx,y+dy), 0xff0000) else: fongoloco=randint(0,270) if fongoloco<=100: colorci=randint(0,255) colorcia=randint(0,255) colorcib=randint(0,255) colorcillos=(colorci,colorcia,colorcib) if (fongoloco>100 and fongoloco<=200): colorci=randint(0,255) colorcia=randint(0,50) colorcib=randint(0,20) colorcillos=(colorci,colorcia,colorcib) if (fongoloco>200 and fongoloco<=225): colorcillos=(0,255,0) if (fongoloco>225 and fongoloco<=250): colorcillos=(0,0,255) if fongoloco>250: colorcillos=(255,244,0) canvas.line((x,y,x+dx,y+dy), colorcillos) x += dx y += dy p += 1 if p % 20 == 0: e32.ao_sleep(0.01) else: dragon(level-1, 0) if turn: dx, dy = dy, -dx else: dx, dy = -dy, dx dragon(level-1, 1) def quit(): appuifw.app.exit_key_handler = None lock = e32.Ao_lock() old_screen=appuifw.app.screen old_body=appuifw.app.body appuifw.app.exit_key_handler = quit appuifw.app.screen='full' canvas=appuifw.Canvas() appuifw.app.body=canvas x, y = randint(30,110),randint(111,160) dx, dy = 1, 0 p = 0 if int(coloresa)==1: for folia in xrange(0,int(cuanto),1): e32.ao_yield() dragon(int(kkk),0) e32.ao_yield() im = graphics.screenshot() im.save(u"e:\\images\\snap\\CurvaDragon-"+str(lulu)+".jpg") print "\nGrafico N. "+str(lulu)+" Completado..." lulu+=1 x, y = randint(30,110),randint(111,160) dx, dy = 1, 0 p = 0 canvas.clear(0) if int(fondo)==1: canvas.rectangle((0,0,176,208), fill = 0xffffff) else: fofo1=randint(0,255) fofo2=randint(0,255) fofo3=randint(0,255) fofo4=(fofo1,fofo2,fofo3) canvas.rectangle((0,0,176,207),fill=fofo4) else: dragon(int(kkk), 0) im = graphics.screenshot() im.save(u"e:\\images\\snap\\CurvaDragon.jpg") print "\nImagenes Grabadas En MMC. 1" if int(coloresa)==1: print "\nImagenes Grabadas En MMC. "+str(lulu) canvas=None appuifw.app.body=old_body appuifw.app.screen=old_screen print "\n^MvIiIaX^ Corp. 2006" app=appuifw.app app.screen='full' c = appuifw.Canvas() appuifw.app.body=c draw = graphics.Draw(c) dibujando = 1 strip = 0 scene = 1 def set_exit(): global dibujando dibujando = 0 def cartoon(): try: menu = graphics.Image.open(u"E:\\images\\snap\\curvadragon-%s.jpg" %strip) if scene == 1: menu.blit(menu, source=(10,13)) if scene == 2: menu.blit(menu, source=(217,13)) if scene == 3: menu.blit(menu, source=(415,13)) c.blit(menu) except KErrNotFound: pass def m_dir(dx, dy): global scene, strip scene = scene + dx if scene == 4: scene = 1 strip = strip + 1 if scene == 0: scene = 3 strip = strip - 1 strip = strip + dy cartoon() def save_mark(): myfile = open("d:\\Mark.txt", "w") myfile.write(strip) myfile.close() def open_mark(): myfile = open("d:\\Mark.txt") strip = myfile.read() myfile.close() app.exit_key_handler= set_exit c.bind(EKeyRightArrow,lambda:m_dir(1, 0)) c.bind(EKeyLeftArrow,lambda:m_dir(-1, 0)) c.bind(EKeyUpArrow,lambda:m_dir(0, -1)) c.bind(EKeyDownArrow,lambda:m_dir(0, 1)) c.bind(EKey1,lambda:m_dir(-1, 0)) c.bind(EKey2,lambda:m_dir(0, -1)) c.bind(EKey3,lambda:m_dir(1, 0)) c.bind(EKey5,lambda:m_dir(0, 1)) c.bind(EKeyHash,lambda:set_exit()) c.bind(EKeyStar,lambda:save_mark()) c.bind(EKey0,lambda:open_mark()) while dibujando: e32.ao_sleep(0.1)