24 lines
608 B
Python
24 lines
608 B
Python
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)
|
|
|