def __init__(self, x1, y1, x2, y2): self.x1 = x1 self.y1 = y1 self.x2 = x2 self.y2 = y2 self.line = pytweening.getLine(x1, y1, x2, y2) self.anim_turn = 0
def test_startAndEndCoordinates(self): points = [(79, 16), (-67, -44), (-95, -56), (98, 47), (72, -6), (97, -63), (-38, -39), (91, -31), (-35, 96), (-72, 64), (-42, 11), (-11, 8), (-8, -35), (4, -27), (-51, -46), (33, -95), (94, -96), (-94, -77), (6, 28), (-82, -48)] for startPoint in points: for endPoint in points: linePoints = pytweening.getLine(startPoint[0], startPoint[1], endPoint[0], endPoint[1]) self.assertEqual(startPoint, linePoints[0], 'Start point returned from getLine() is not the same as the original start point.') self.assertEqual(endPoint, linePoints[-1], 'End point returned from getLine() is not the same as the original end point.') x, y = pytweening.getPointOnLine(startPoint[0], startPoint[1], endPoint[0], endPoint[1], 0.0) self.assertEqual((int(x), int(y)), (linePoints[0][0], linePoints[0][1]), 'Start point of getPointOnLine() is not the same as the line\'s start point.') x, y = pytweening.getPointOnLine(startPoint[0], startPoint[1], endPoint[0], endPoint[1], 1.0) self.assertEqual((int(x), int(y)), (linePoints[-1][0], linePoints[-1][1]), 'End point of getPointOnLine() is not the same as the line\'s end point.')
def get_distance(self, robot, mask): """ Расчёт расстояния до препятствия :param robot: позиция робота :param mask: маска лабиринта :return: число от 0 до 6 """ start_x, start_y = self.start_func(robot) end_x, end_y = self.end_func(robot) for point in pytweening.getLine(start_x, start_y, end_x, end_y): try: if mask.get_at(point): return self.distance_func(point, start_x, start_y) except IndexError: return 0 return 6
def __tween(self, pirate, x1, y1, x2, y2, angle): points = pytweening.getLine(x1, y1, x2, y2) for point in points: pirate.coors.append((angle, point[0], point[1])) del pirate.coors[-1]
for newWave in new_Waves: waveIndex += 1 waveList.append(newWave) print 'New Wave(t={0:.4f}) Type: {1}'.format(newWave.createdAt, newWave.wave_type) LastWaveCreatedAt = time.time() wave_spawn_timer = 0.0 for wave in waveList: wave.TimerUpdate() if wave.delete_flag: print "Removing Wave: %s" % wave.name waveList.remove(wave) # create the correct line. line = pytweening.getLine(wave.x1, wave.y1, wave.x2, wave.y2) applyNormalPoints(line) # drain normal values drainNormals(drainAmount) # calculate pixel color values based on normalArray pixels = make_pixelarray_from_normals(coordinates) #pixels = make_pixels_random(numLEDs) ## Create pixel array and push to client. # pixels = make_pixelarray(coordinates, t) client.put_pixels(pixels, channel) time.sleep(1 / options.fps)
def setPathToPoint(self,x,y): self.path = tween.getLine(self.x,self.y,x,y) return self.path
def start_move(self, end_coords): self.move_list = pytweening.getLine(self.x, self.y, end_coords[0], end_coords[1]) self.move_list.append(end_coords)