All pastes #1006699 Raw Edit

Paul

public python v1 · immutable
#1006699 ·published 2008-05-04 05:18 UTC
rendered paste body
#!/usr/bin/pythonimport Imageimport sysim = Image.open("test.bmp")ix, iy = im.sizeif ix > 256 or iy > 180:  print "too big!"  sys.exit(0)BASE_X = 50BASE_Y = 220pix = im.load()down = Falsefor y in range(iy):  for x in range(ix):    new_down = (pix[x, y] == 0)    if new_down and not down:      print "mousemove %d %d" % (BASE_X + x*3, BASE_Y + y*3)      print "mousedown 1"    elif not new_down and down:      print "mousemove %d %d" % (last_draw_x, last_draw_y)      print "mouseup 1"    last_draw_x, last_draw_y = (BASE_X + x*3, BASE_Y + y*3)    down = new_down  down = False  print "mousemove %d %d" % (last_draw_x, last_draw_y)  print "mouseup 1"