Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1. from PIL import Image, ImageDraw
  2.  
  3. im = Image.open("s.png")
  4. draw = ImageDraw.Draw(im)
  5.  
  6. #draw.setfill()
  7.  
  8. im.load()
  9. #print im.getpixel((1395+5,3335+5))
  10. #im.putpixel((25,26),123)
  11. #im.save("tmp.png")
  12. #quit()
  13.  
  14. def checkbox(x, y):
  15.     if ((im.getpixel((x,y))[0] + im.getpixel((x+3,y))[0] + im.getpixel((x,y+3))[0]) == 0) and im.getpixel((x-1,y))[0] == 190 and im.getpixel((x,y-1))[0] == 190:
  16.         redraw(x,y)
  17.  
  18. def redraw(x,y):
  19.     print str(x) + ":"+str(y)+"\n"
  20.    
  21.     own_color = im.getpixel((x+3,y+3))[0]
  22.      
  23.     draw.rectangle((x,y,x+11,y+11),fill=(190,190,190))
  24.     draw.line((x,y+5,x+11,y+5),fill=0)
  25.          
  26.     if im.getpixel((x+5,y+13))[0] == 0: #down line
  27.         draw.line((x+5,y+5,x+5,y+11),fill=0)
  28.     else: #upper line
  29.         draw.line((x+5,y,x+5,y+5),fill=0)
  30.    
  31. im.putpixel((x+5,y+5),own_color+25)  # 25 + own color of box    
  32.  
  33.  
  34. for x in range(1,im.size[0]-3):
  35.     for y in range(1,im.size[1]-3):
  36.         if im.getpixel((x,y))[0] == 0:
  37.             checkbox(x,y)
  38.            
  39. im.save("tmp.png")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement