Hardware Reference
In-Depth Information
Listing 15-5 continued
if event.key == K_k : # draw in blacK
col = (0, 0, 0)
if event.key == K_s : # save current point
last_reading[2] = last_reading[0] # save X
last_reading[3] = last_reading[1] # save Y
if event.key == K_l : # draw a line to saved point
pygame.draw.line(segment,col,(last_reading[2],;
last_reading[3]),(last_reading[0],last_reading[1]),2)
screenUpdate()
if event.key == K_c : # draw a circle
try :
r = ((last_reading[0] - last_reading[2]);
**2 + (last_reading[1] - last_reading[3])**2 ) ** (0.5)
pygame.draw.circle(segment,col,;
(last_reading[0],last_reading[1]),int(r),2)
screenUpdate()
except:
pass
if event.key == K_HASH :
#Save folder to Flickr / Facebook
print “sending folder to Flickr”
subprocess.check_output(“python ;
folders2flickr/uploadr.py”,shell=True)
print “done”
if event.key == K_HOME : # save a picture
print “save sketch to file”
if picture == 1 : # first time to save this session
fileName = raw_input(“Enter file name ;
for this session “)
try:
pygame.image.save(screen, ;
'roto-sketch/'+fileName+str(picture)+'.png')
except:
os.system('mkdir roto-sketch')
pygame.image.save(screen, ;
'roto-sketch/'+fileName+str(picture)+'.png')
print “saving sketch as “,;
'roto-sketch/'+fileName+str(picture)+'.png'
picture +=1;
if __name__ == '__main__':
main()
Search WWH ::




Custom Search