def generate_path(self, pointList, up_Z=-1, down_Z=-1):
""" Generate path for a line of the image. """
count = 0
toEnd = NOT_ADJUST_THICKNESS
start_point = self.robotCoorToPygameCoor( pointList[0] )
for (x, y) in pointList:
upZ = self.up_z if up_Z == -1 else up_Z
downZ = self.down_z if down_Z == -1 else down_Z
if_draw = True
end_point = self.robotCoorToPygameCoor( (x, y) )
pygame.draw.line(self.screen, BLACK, start_point, end_point, PYGAME_LINE_WIDTH)
pygame.display.update()
if not toEnd:
pressed_key = self.pygame_wait()
if (pressed_key == pygame.K_a):
downZ -= Z_THICK_ADJUST
pygame.draw.line(self.screen, BLACK, start_point, end_point, PYGAME_THICK_LINE_WIDTH)
pygame.display.update()
elif (pressed_key == pygame.K_d):
downZ += Z_THIN_ADJUST
pygame.draw.line(self.screen, WHITE, start_point, end_point, PYGAME_LINE_WIDTH)
pygame.draw.line(self.screen, BLACK, start_point, end_point, PYGAME_THIN_LINE_WIDTH)
elif (pressed_key == pygame.K_e):
toEnd = True
elif (pressed_key == pygame.K_p):
pygame.draw.line(self.screen, WHITE, start_point, end_point, PYGAME_LINE_WIDTH)
if_draw = False
start_point = end_point
if if_draw:
""" Move to the stating point. """
if count == 0:
self.create_robot_point(x, y, upZ)
self.create_robot_point(x, y, downZ)
""" Move to the last point. """
if count == len(pointList) -1:
self.create_robot_point(x, y, upZ)
count += 1
drawSVG.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录