You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.5KB

  1. #!/bin/env python3
  2. from inky import InkyPHAT
  3. from PIL import Image, ImageDraw, ImageFont
  4. from fonts.ttf import SourceSansPro
  5. inky_display = InkyPHAT("red")
  6. WHITE = inky_display.WHITE
  7. BLACK = inky_display.BLACK
  8. RED = inky_display.RED
  9. img = Image.new("P", (inky_display.WIDTH, inky_display.HEIGHT))
  10. draw = ImageDraw.Draw(img)
  11. # Picture frame
  12. text = "Picture\nHere"
  13. font = ImageFont.truetype(SourceSansPro, 24)
  14. draw.rectangle((1,1,100,100), outline=BLACK)
  15. w,h = draw.multiline_textsize(text, font)
  16. draw.multiline_text(((100 - w) / 2, (100 - h) / 2), text, BLACK, font, align="center")
  17. left = 104
  18. top = 0
  19. # Name tag
  20. text = "Terrana"
  21. draw.text((left, top), text, BLACK, font)
  22. w,h = font.getsize(text)
  23. top += h + 4
  24. # Dividing line
  25. draw.line((left, top, inky_display.WIDTH - 5, top), BLACK)
  26. top += 4
  27. # HP bar
  28. text = "HP"
  29. font = ImageFont.truetype(SourceSansPro, 16)
  30. w,h = font.getsize(text)
  31. draw.text((left, top), text, BLACK, font)
  32. left_indent = left + w + 2
  33. draw.rectangle((left_indent, top + 2, inky_display.WIDTH - 5, top + h), outline=BLACK)
  34. draw.rectangle((left_indent + 3, top + 5, inky_display.WIDTH - 8, top + h - 3), fill=RED)
  35. draw.text((left_indent, top + h), "100 / 100", BLACK, font)
  36. top += 2 * h + 2
  37. # Misc stats
  38. text = "STR: 4\nORP: -3"
  39. draw.multiline_text((left, top), text, BLACK, font, align="left")
  40. text = "DEX: 8\nFUD: π"
  41. draw.multiline_text((left + (inky_display.WIDTH - left) / 2, top), text, BLACK, font, align="left")
  42. inky_display.set_image(img)
  43. inky_display.show()