Skip to content

Instantly share code, notes, and snippets.

@aquarion
Created August 7, 2011 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aquarion/1130256 to your computer and use it in GitHub Desktop.
Save aquarion/1130256 to your computer and use it in GitHub Desktop.
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