def apag(eve): global REVES if eve.char == "r" or eve.char == "R": c.delete("all") c.create_rectangle(0, 0, xt, yt, width=0, fill="black") if eve.char == "p" or eve.char == "P": # printa imagem pra mandar if not os.path.exists("images"): os.mkdir("images") fl = os.listdir("images") fl = filter(ispic, fl) fl.sort() n = 1 if len(fl): ru = re.compile("_(\d+)\.jpg") gu = ru.search(fl.pop()) if gu != None: n = int(gu.group(1)) + 1 c.postscript(file="images/pic_" + (str(n).zfill(5)) + ".eps") # save canvas as encapsulated postscript import subprocess as sp child = sp.Popen( "mogrify -format jpg images/pic_" + (str(n).zfill(5)) + ".eps", shell=True ) # convert eps to jpg with ImageMagick child.wait() if eve.char == "a" or eve.char == "A": barulho.toca(put) REVES = not REVES if eve.char == "q" or eve.char == "Q": exit()
def run(self): capture = cv.CaptureFromCAM(0) tf="" showtime=None for i in range(0,self.veces): cc = cv.QueryFrame(capture) tf="output/photo_"+str('%05d' % self.n)+"_"+str(int(time.time()))+".png" if not showtime: showtime=tf cv.SaveImage(tf,cc) time.sleep(1) barulho.toca("camera.mp3") self.emit(QtCore.SIGNAL('postsave(QString)'), tf)
def go(self): sta = "fm_synthesis_effect_5_good_for_sci_fi_sounds.mp3" put = "punch25.mp3" X = 1024 Y = 768 A = 60 / 360.0 * 2 * math.pi # angulo da lente D = 0.2 DELAY = 20 DAC = 40 # imx=Image.new("RGB", [1000, 50]) # draw = ImageDraw.Draw(imx) ok = False wm = None while not ok: try: print "Press 1+2 on your Wiimote now..." wm = cwiid.Wiimote() ok = True except RuntimeError: print "Bluetooth esta mal." time.sleep(2) barulho.toca(sta) wm.rpt_mode = cwiid.RPT_BTN | cwiid.RPT_ACC i = 0 things = [] while self.soq.connect: time.sleep(0.01) # print wm.state x = wm.state["acc"][0] y = wm.state["acc"][1] z = wm.state["acc"][2] things.append(y) # draw.rectangle([i, x-100, 1+i, x-99], fill='#ff0000', outline=None) # draw.rectangle([i, y-100, 1+i, y-99], fill='#00ff00', outline=None) # draw.rectangle([i, z-100, 1+i, z-99], fill='#0000ff', outline=None) siny = (y - 100) / 50.0 if siny > 1: siny = 1 if siny < -1: siny = -1 angle = math.asin(siny) # print angle if len(things) > DELAY: old = things.pop(0) if y - old > DAC: barulho.toca(put) things = things[DELAY / 3 : DELAY] self.soq.send(str.encode(str(y - old) + "\0")) i += 1 if wm.state["buttons"] & 4 == 4: print "B pressed" self.soq.close() break # imx.save("x.png") barulho.toca("alert_sound_ideal_for_software_systems_etc_ver_15.mp3")
def runner(tela, wii): global REVES zona = Image.new("RGBA", (xt, yt), (0, 0, 0)) canv = ImageTk.PhotoImage(zona) tela.create_image(xt / 2, yt / 2, image=canv) masquerades = {} cor = 0 pitch = 0 roll = 0 palha = None maska = None maskara = None stencil = None mu = None while 1: if wii: cur = ImageTk.PhotoImage(curry) ps = filter(mtest, wii.state["ir_src"]) dist = 0 du = 0 mid = [] if wii.state["buttons"] & 2048: if len(ps) > 1: du = pow( pow(ps[1]["pos"][0] - ps[0]["pos"][0], 2) + pow(ps[1]["pos"][1] - ps[0]["pos"][1], 2), 0.5 ) DISTA[1] = int(du) pitch = math.asin(zangle(wii.state["acc"][1])) roll = math.asin(zangle(wii.state["acc"][0])) print "distancia mínima" print DISTA saveconf() if wii.state["buttons"] & 1024: if len(ps) > 1: du = pow( pow(ps[1]["pos"][0] - ps[0]["pos"][0], 2) + pow(ps[1]["pos"][1] - ps[0]["pos"][1], 2), 0.5 ) DISTA[0] = int(du) print "distancia máxima" print DISTA saveconf() if len(ps) > 1: du = pow(pow(ps[1]["pos"][0] - ps[0]["pos"][0], 2) + pow(ps[1]["pos"][1] - ps[0]["pos"][1], 2), 0.5) dist = int(sprawl(du)) xo = (ps[0]["pos"][0] + ps[1]["pos"][0]) / 2.0 yo = (ps[0]["pos"][1] + ps[1]["pos"][1]) / 2.0 if ps[1]["pos"][0] != ps[0]["pos"][0]: teta = math.atan( 1.0 * (ps[1]["pos"][1] - ps[0]["pos"][1]) / (ps[1]["pos"][0] - ps[0]["pos"][0]) ) else: teta = math.pi / 2.0 # if REVES : # teta -= math.pi / 2.0 x = xp * (512 + (xo - 512) * math.cos(teta) + (yo - 384) * math.sin(teta)) y = yp * (384 + (yo - 384) * math.cos(teta) - (xo - 512) * math.sin(teta)) # coordenadas para tela: xu = int(x) yu = int(y) if REVES: yu = yt - yu # if not REVES : xu = int(xt - x) if wii.state["buttons"] & 4: if palha: yk = yu - (PAL[1] - 267) if yk > 0 and yk < 535: cor = int(math.floor(12 * (yk - 18) / 535)) elif maska: mk = xu - (MAS[0] - 282) if mk > 0 and mk < 566: maskara = int(math.floor(5 * mk / 560)) print "i've set up maskara as " + str(maskara) else: gradient = imf[dist][cor] if mu != None: if not cor in masquerades: masquerades[cor] = {} if not maskara in masquerades[cor]: masquerades[cor][maskara] = {} if not teta in masquerades[cor][maskara]: j = masks[maskara].rotate(teta / (2 * math.pi) * -360).copy() masquerades[cor][maskara][teta] = ImageTk.PhotoImage(pinta(j, colors[cor])) # mi=ImageTk.PhotoImage(masquerades[cor][maskara][teta]) tela.create_image(xu, yu, image=masquerades[cor][maskara][teta]) # zona.paste(pinta(j,colors[cor]), (xu-j.size[0]/2,yu-j.size[1]/2),j) # canv = ImageTk.PhotoImage(zona) # tela.create_image(xt/2,yt/2, image=canv) # tela.delete(mu) ant = None else: tela.create_image(xu, yu, image=gradient) # zona.paste(ims[dist][cor], (xu-dist/2,yu-dist/2), ims[dist][cor]) # canv = ImageTk.PhotoImage(zona) # tela.create_image(xt/2,yt/2, image=canv) ago = {"x": xu, "y": yu} # if not not ant : # du = distancia(ago, ant) # if du > dist : # passos = 2.5 * du / dist # if passos < 25 : # inc = {'x':(ago['x']-ant['x'])/passos,'y':(ago['y']-ant['y'])/passos } # for pu in range(0, int(passos)) : # ago['x'] += inc['x'] # ago['y'] += inc['y'] # #zona.paste(ims[dist][cor], (int(ago['x']-dist/2),int(ago['y']-dist/2)), ims[dist][cor]) # tela.create_image(int(ago['x']), int(ago['y']), image=gradient) # tela.create_image(xt/2,yt/2, image=canv) ant = {"x": xu, "y": yu} else: ant = None if xu < PAL[0]: if not palha: palha = tela.create_image(PAL[0], PAL[1], image=pal) if not not palha: if xu > PAL[0] + 100: tela.delete(palha) palha = None if yu < MAS[1]: if not maska: maskara = None if mu: tela.delete(mu) mu = None maska = tela.create_image(MAS[0], MAS[1], image=mas) if not not maska: if yu > MAS[1] + 200: tela.delete(maska) maska = None if wii.state["buttons"] & 256: PAL[0] = int(xu) PAL[1] = int(yu) saveconf() if wii.state["buttons"] & 512: MAS[0] = int(xu) MAS[1] = int(yu) saveconf() tela.create_image(xu, yu, image=cur) if maskara != None: if not masks[maskara]: maskara = None elif not wii.state["buttons"] & 4: stencil = ImageTk.PhotoImage(masks[maskara].rotate(teta / (2 * math.pi) * -360)) mu = tela.create_image(xu, yu, image=stencil) else: ant = None if wii.state["buttons"] & 1: tela.delete("all") tela.create_rectangle(0, 0, xt, yt, width=0, fill="black") # zona = Image.new('RGBA', (xt,yt), (0,0,0)) # canv = ImageTk.PhotoImage(zona) if wii.state["buttons"] & 8: barulho.toca(put) REVES = not REVES while wii.state["buttons"] & 8: print "peraí" if wii.state["buttons"] & 2: break
def run(self): barulho.toca("beep.mp3")