Browse Source

Initial commit

master
Terrana 2 years ago
commit
d5dd71e27b
1 changed files with 52 additions and 0 deletions
  1. +52
    -0
      inkytest.py3

+ 52
- 0
inkytest.py3 View File

@@ -0,0 +1,52 @@
#!/bin/env python3
from inky import InkyPHAT
from PIL import Image, ImageDraw, ImageFont
from fonts.ttf import SourceSansPro

inky_display = InkyPHAT("red")
WHITE = inky_display.WHITE
BLACK = inky_display.BLACK
RED = inky_display.RED

img = Image.new("P", (inky_display.WIDTH, inky_display.HEIGHT))
draw = ImageDraw.Draw(img)

# Picture frame
text = "Picture\nHere"
font = ImageFont.truetype(SourceSansPro, 24)
draw.rectangle((1,1,100,100), outline=BLACK)
w,h = draw.multiline_textsize(text, font)
draw.multiline_text(((100 - w) / 2, (100 - h) / 2), text, BLACK, font, align="center")

left = 104
top = 0

# Name tag
text = "Terrana"
draw.text((left, top), text, BLACK, font)
w,h = font.getsize(text)
top += h + 4

# Dividing line
draw.line((left, top, inky_display.WIDTH - 5, top), BLACK)
top += 4

# HP bar
text = "HP"
font = ImageFont.truetype(SourceSansPro, 16)
w,h = font.getsize(text)
draw.text((left, top), text, BLACK, font)
left_indent = left + w + 2
draw.rectangle((left_indent, top + 2, inky_display.WIDTH - 5, top + h), outline=BLACK)
draw.rectangle((left_indent + 3, top + 5, inky_display.WIDTH - 8, top + h - 3), fill=RED)
draw.text((left_indent, top + h), "100 / 100", BLACK, font)
top += 2 * h + 2

# Misc stats
text = "STR: 4\nORP: -3"
draw.multiline_text((left, top), text, BLACK, font, align="left")
text = "DEX: 8\nFUD: π"
draw.multiline_text((left + (inky_display.WIDTH - left) / 2, top), text, BLACK, font, align="left")

inky_display.set_image(img)
inky_display.show()

Loading…
Cancel
Save