Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. import json
  2. from PIL import Image, ImageDraw
  3.  
  4. with open("dates.json") as fp:
  5.     dates = json.load(fp)
  6.  
  7. dates.sort()
  8.  
  9. print(dates[:10])
  10.  
  11. new_dates = []
  12.  
  13. for date in dates:
  14.     new_dates.append(int(date/86400)-int(dates[0]/86400))
  15.  
  16. print(new_dates[-1])
  17.  
  18. im = Image.new("RGB", (new_dates[-1]+1, len(new_dates)))
  19. draw = ImageDraw.Draw(im)
  20.  
  21. currentpixel = 0
  22. totalMember = 0
  23.  
  24. for date in new_dates:
  25.     totalMember += 1
  26.     for i in range(currentpixel, date-currentpixel):
  27.         draw.line((im.height, im.height-totalMember, i, im.height-totalMember), fill=(0, 180, 0))
  28.     currentpixel = date
  29.     draw.line((im.height, im.height-totalMember, currentpixel, im.height-totalMember), fill=(0, 180, 0))
  30.    
  31. im.save("output.png", "png")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement