Skip to content

Commit c124a8d

Browse files
committed
Examples: added new examples for 4 colour displays
1 parent d6ea5fd commit c124a8d

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This basic example shows how to draw shapes and text on Inky pHAT using PIL.
2+
3+
from font_fredoka_one import FredokaOne
4+
from PIL import Image, ImageDraw, ImageFont
5+
6+
from inky.auto import auto
7+
8+
inky_display = auto(ask_user=True, verbose=True)
9+
10+
WIDTH, HEIGHT = inky_display.width, inky_display.height
11+
12+
# Create new PIL image with a white background
13+
image = Image.new("P", (WIDTH, HEIGHT), inky_display.WHITE)
14+
draw = ImageDraw.Draw(image)
15+
16+
font = ImageFont.truetype(FredokaOne, 18)
17+
18+
# draw some shapes
19+
draw.rectangle((100, 0, 170, 50), fill=inky_display.YELLOW) # Rectangle
20+
draw.ellipse((90, 90, 180, 180), fill=inky_display.RED) # Circle (ellipse)
21+
22+
23+
# draw some text
24+
draw.text((80, 60), "Hello, World!", inky_display.BLACK, font)
25+
26+
inky_display.set_image(image)
27+
inky_display.show()
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# This basic example shows how to draw shapes and text on Inky wHAT using PIL.
2+
3+
from font_fredoka_one import FredokaOne
4+
from PIL import Image, ImageDraw, ImageFont
5+
6+
from inky.auto import auto
7+
8+
inky_display = auto(ask_user=True, verbose=True)
9+
10+
WIDTH, HEIGHT = inky_display.width, inky_display.height
11+
12+
# Create new PIL image with a white background
13+
image = Image.new("P", (WIDTH, HEIGHT), inky_display.WHITE)
14+
draw = ImageDraw.Draw(image)
15+
16+
font = ImageFont.truetype(FredokaOne, 28)
17+
18+
# draw some shapes
19+
draw.rectangle((0, 0, 200, 200), fill=inky_display.YELLOW) # Rectangle
20+
draw.ellipse((200, 200, 400, 400), fill=inky_display.RED) # Circle (ellipse)
21+
22+
# draw some text
23+
draw.text((120, 130), "Hello, World!", inky_display.BLACK, font)
24+
25+
inky_display.set_image(image)
26+
inky_display.show()

0 commit comments

Comments
 (0)