Compare commits
2 Commits
b50cfeaac8
...
8a54cedb5b
Author | SHA1 | Date |
---|---|---|
|
8a54cedb5b | |
|
8e3b3abe8a |
Binary file not shown.
|
@ -1,8 +1,20 @@
|
||||||
import time
|
import time
|
||||||
from PIL import Image, ImageDraw
|
|
||||||
|
|
||||||
def testScreen(x=1280, y=720, image=None, stripeList = ["red", "green", "blue", "orange", "purple"]):
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
if image == None:
|
|
||||||
|
|
||||||
|
def testScreen(
|
||||||
|
x=1280, y=720,
|
||||||
|
image=None,
|
||||||
|
stripeList=["lightgrey",
|
||||||
|
"yellow",
|
||||||
|
"cyan",
|
||||||
|
"lightgreen",
|
||||||
|
"magenta",
|
||||||
|
"red",
|
||||||
|
"blue"]):
|
||||||
|
|
||||||
|
if image is None:
|
||||||
image = Image.new("RGB", (x, y))
|
image = Image.new("RGB", (x, y))
|
||||||
|
|
||||||
draw = ImageDraw.Draw(image)
|
draw = ImageDraw.Draw(image)
|
||||||
|
@ -13,11 +25,55 @@ def testScreen(x=1280, y=720, image=None, stripeList = ["red", "green", "blue",
|
||||||
(x/len(stripeList)) * (i + 1), x),
|
(x/len(stripeList)) * (i + 1), x),
|
||||||
fill=stripe)
|
fill=stripe)
|
||||||
|
|
||||||
|
draw.rectangle((
|
||||||
|
0, y - (y/3),
|
||||||
|
x, y),
|
||||||
|
fill="black")
|
||||||
|
|
||||||
|
for i, stripe in enumerate(stripeList):
|
||||||
|
if i % 2 != 0:
|
||||||
|
_fill = "black"
|
||||||
|
else:
|
||||||
|
_fill = stripeList[len(stripeList) - i - 1]
|
||||||
|
|
||||||
|
draw.rectangle((
|
||||||
|
(x/len(stripeList)) * i, y - (y/3.1),
|
||||||
|
(x/len(stripeList)) * (i + 1), y - (y/4.9)),
|
||||||
|
fill=_fill)
|
||||||
|
|
||||||
|
draw.rectangle((
|
||||||
|
(x/(len(stripeList)/4)), y - (y/5.3),
|
||||||
|
(0), y),
|
||||||
|
fill="darkblue")
|
||||||
|
|
||||||
|
draw.rectangle((
|
||||||
|
(x/(len(stripeList)/2)), y - (y/5.3),
|
||||||
|
(x/(len(stripeList)/1)), y),
|
||||||
|
fill="white")
|
||||||
|
|
||||||
return image
|
return image
|
||||||
|
|
||||||
|
|
||||||
|
def drawText(image):
|
||||||
|
# get a font
|
||||||
|
fnt = ImageFont.truetype("FreeMono.ttf", 50)
|
||||||
|
# get a drawing context
|
||||||
|
d = ImageDraw.Draw(image)
|
||||||
|
|
||||||
|
# draw multiline text
|
||||||
|
d.multiline_text((10, 10), str(time.time()), font=fnt, fill=(0, 0, 0))
|
||||||
|
|
||||||
|
return image
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
masterList = ["red", "white", "blue", "green", "orange", "purple", "cyan", "magenta"]
|
blank_screen = testScreen()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
for i in range(len(masterList)):
|
annotated_image = drawText(blank_screen.copy())
|
||||||
testScreen(stripeList=masterList[i:]).save('Test-Pattern.png')
|
|
||||||
time.sleep(1)
|
annotated_image.save('Test-Pattern.png')
|
||||||
|
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
# testScreen().save('Test-Pattern.png')
|
||||||
|
|
Loading…
Reference in New Issue