Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
from map.pathfinding.route import Route
from PIL import Image, ImageDraw
def drawCross(coords, image, color=255, size=10, width=3):
draw = ImageDraw.Draw(image)
cross1 = [ (coords[0]-size, coords[1]-size), (coords[0]+size, coords[1]+size) ]
cross2 = [ (coords[0]+size, coords[1]-size), (coords[0]-size, coords[1]+size) ]
draw.line(cross1, fill=color, width=width)
draw.line(cross2, fill=color, width=width)
del draw
def main():
map = Route()
start_pos = (264,500)
goal_pos = (704,670)
waypoints = map.generate_route(start_pos, goal_pos)
filename = "map/data/rendered.png"
cp = Image.open(filename)
drawCross(start_pos, cp, color='#FF0000')
drawCross(goal_pos, cp, color='#00FF00')
lastplace = start_pos
draw = ImageDraw.Draw(cp)
draw.line(waypoints, fill=255, width=2)
for place in waypoints:
drawCross(place, cp, color='#FFFFFF', size=5, width=2)
del draw
cp.show()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.