many works
This commit is contained in:
parent
9bd764579a
commit
c937450f92
7 changed files with 151 additions and 36 deletions
24
lib/helpers.py
Normal file
24
lib/helpers.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
def triangle(image_draw, offset_x, offset_y, direction, width, height):
|
||||
"""Show triangle. Direction is -1 (down) or 1 (up)."""
|
||||
points = []
|
||||
color = None
|
||||
|
||||
if direction==1:
|
||||
points = [
|
||||
(width/2, 0), # n
|
||||
(0, height), # sw
|
||||
(width, height) # se
|
||||
]
|
||||
color = (0, 255, 0) # green
|
||||
else:
|
||||
points = [
|
||||
(width/2, height), # s
|
||||
(0, 0), # nw
|
||||
(width,0) # ne
|
||||
]
|
||||
color = (255, 0, 0) # red
|
||||
|
||||
# Draw a filled green triangle
|
||||
points = [(x+offset_x, y+offset_y) for (x,y) in points]
|
||||
image_draw.polygon(points, fill=color)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue