def plotMaze(grid, d=20, name="SquareMaze"): dirs = ((1, 1+1j), (1j, 1+1j), (0, 1j), (0, 1)) draw = Turtle(name, background=True) for square in grid: walls = grid[square] for i, dir_ in enumerate(dirs): if walls[1j**i]: draw.addLine((square + dir_[0])*d, (square + dir_[1])*d) draw.dumpImage()
def star(): step = 20 side = 250 shift = side + 1j*side draw = Turtle("star") for x, y in product([1, -1], [1, -1]): for i in xrange(0, side + 1, step): a = x*i + shift b = y*1j*(side - i) + shift draw.addLine(a, b) draw.dumpImage()
draw.right(angle) draw.penUp() if __name__ == "__main__": draw = Turtle("test_pictures") draw.penUp() draw.setCoord(-50, -50) draw.forward(100) draw.right(90) draw.forward(50) draw.left(90) regularPolygon(draw, 100, 5) draw.resetDir() draw.right(36) star(draw, 100 * (sin(108 / 360. * 2 * pi) / sin(36 / 360. * 2 * pi)), 5) draw.resetDir() draw.forward(300) verticies = regularPolygon(draw, 100, 5) for i, vortex in enumerate(verticies[:3]): draw.addLine(vortex, verticies[(i + 2) % len(verticies)]) draw.addLine(vortex, verticies[(i + 3) % len(verticies)]) draw.setCoord(235, 50) star(draw, 150, 13) draw.dumpImage()