def bezier3x_lines(self, data, canvas, i): # points = [[beginning], [beginning_midifier], [end], [end_midifier]] # points = [[200, 400], [300, 250], [450, 500], [500, 475]] canvas_w = self.layout.game_w canvas_h = self._step * data[3] x_center = self.layout.game_w // 2 y_center = self._step * data[3] // 2 bezier = [[[0, 0] for j in range(4)] for j in range(3)] # line 1 start bezier[0][0] = Vector2(self.start_positions[i]) bezier[0][1] = Vector2( random.randrange(self._step, canvas_w - self._step), random.randrange(self._step * 2, canvas_h - self._step)) # mod1 #first point modifier # line 1 end bezier[0][2] = Vector2( random.randrange(self._step, canvas_w - self._step), random.randrange(self._step, canvas_h - self._step)) # first line end bezier[0][3] = Vector2( ex.rand_safe_curve(bezier[0][2], canvas_w, canvas_h)) # line 2 start bezier[1][0] = bezier[0][2] bezier[1][1] = bezier[0][2] + Vector2(-(Vector2.from_points( bezier[0][2], bezier[0][3]))) # 3rd point modifier # line 2 end if bezier[0][2][ 0] > x_center: # if first point is on the right the second will be on the left x_range = [self._step, x_center] else: x_range = [x_center, canvas_w - self._step] if bezier[0][2][ 1] > y_center: # if first point is on the bottom the second will be on the over the center y_range = [self._step, y_center] else: y_range = [y_center, canvas_h - self._step] bezier[1][2] = Vector2(random.randrange(*x_range), random.randrange(*y_range)) # second line end bezier[1][3] = Vector2( ex.rand_safe_curve(bezier[1][2], canvas_w, canvas_h)) # line 3 start bezier[2][0] = bezier[1][2] bezier[2][1] = bezier[1][2] + Vector2(-(Vector2.from_points( bezier[1][2], bezier[1][3]))) # 5th point modifier # line 3 end bezier[2][2] = Vector2(self.end_positions[i]) # last point bezier[2][3] = Vector2( random.randrange(self._step, canvas_w - self._step), random.randrange(self._step, self._step * (data[3] - 1))) # 6th point modifier bezier_points = [] for j in range(3): bezier_points.extend(ex.DrawBezier(bezier[j])) # pygame.draw.aalines(canvas, (0, 0, 0), False, bezier_points) self.ready_lines.append(bezier_points)
def bezier2x_lines(self, data, canvas, i): # points = [[beginning], [beginning_midifier], [end], [end_midifier]] # points = [[200, 400], [300, 250], [450, 500], [500, 475]] canvas_w = self.layout.game_w canvas_h = self._step * data[3] bezier = [[[0, 0] for j in range(4)] for j in range(2)] # line 1 start bezier[0][0] = Vector2(self.start_positions[i]) bezier[0][1] = Vector2(random.randrange(self._step, canvas_w - self._step), random.randrange(self._step * 2, canvas_h - self._step)) # mod1 #first point modifier # line 1 end bezier[0][2] = Vector2(random.randrange(self._step, canvas_w - self._step), random.randrange(self._step, canvas_h - self._step)) # first line end bezier[0][3] = Vector2(ex.rand_safe_curve(bezier[0][2], canvas_w, canvas_h)) # line 3 start bezier[1][0] = bezier[0][2] bezier[1][1] = bezier[0][2] + Vector2(-(Vector2.from_points(bezier[0][2], bezier[0][3]))) # 5th point modifier # line 3 end bezier[1][2] = Vector2(self.end_positions[i]) # last point bezier[1][3] = Vector2(random.randrange(self._step, canvas_w - self._step), random.randrange(self._step, self._step * (data[3] - 1))) # 6th point modifier bezier_points = [] for j2 in range(2): bezier_points.extend(ex.DrawBezier(bezier[j2])) self.ready_lines.append(bezier_points)
def bezier2x_lines(self, data, canvas, i): #points = [[beginning], [beginning_midifier], [end], [end_midifier]] #points = [[200, 400], [300, 250], [450, 500], [500, 475]] canvas_w = self.layout.game_w canvas_h = self._step*data[3] x_center = self.layout.game_w //2 y_center = self._step*data[3]//2 bezier = [[[0,0] for j in range(4)] for j in range(2)] #line 1 start bezier[0][0] = Vector2(self.start_positions[i]) bezier[0][1] = Vector2(random.randrange(self._step,canvas_w-self._step),random.randrange(self._step*2,canvas_h-self._step))#mod1 #first point modifier #line 1 end bezier[0][2] = Vector2(random.randrange(self._step,canvas_w-self._step),random.randrange(self._step,canvas_h-self._step)) #first line end bezier[0][3] = Vector2(ex.rand_safe_curve(bezier[0][2],canvas_w,canvas_h)) #line 3 start bezier[1][0] = bezier[0][2] bezier[1][1] = bezier[0][2] + Vector2(-(Vector2.from_points(bezier[0][2], bezier[0][3]))) #5th point modifier #line 3 end bezier[1][2] = Vector2(self.end_positions[i]) #last point bezier[1][3] = Vector2(random.randrange(self._step,canvas_w-self._step),random.randrange(self._step,self._step*(data[3]-1))) #6th point modifier bezier_points = [] for j2 in range(2): bezier_points.extend(ex.DrawBezier(bezier[j2])) self.ready_lines.append(bezier_points)
def bezier3x_lines(self, data, canvas, i): # points = [[beginning], [beginning_midifier], [end], [end_midifier]] # points = [[200, 400], [300, 250], [450, 500], [500, 475]] canvas_w = self.layout.game_w canvas_h = self._step * data[3] x_center = self.layout.game_w // 2 y_center = self._step * data[3] // 2 bezier = [[[0, 0] for j in range(4)] for j in range(3)] # line 1 start bezier[0][0] = Vector2(self.start_positions[i]) bezier[0][1] = Vector2(random.randrange(self._step, canvas_w - self._step), random.randrange(self._step * 2, canvas_h - self._step)) # mod1 #first point modifier # line 1 end bezier[0][2] = Vector2(random.randrange(self._step, canvas_w - self._step), random.randrange(self._step, canvas_h - self._step)) # first line end bezier[0][3] = Vector2(ex.rand_safe_curve(bezier[0][2], canvas_w, canvas_h)) # line 2 start bezier[1][0] = bezier[0][2] bezier[1][1] = bezier[0][2] + Vector2(-(Vector2.from_points(bezier[0][2], bezier[0][3]))) # 3rd point modifier # line 2 end if bezier[0][2][0] > x_center: # if first point is on the right the second will be on the left x_range = [self._step, x_center] else: x_range = [x_center, canvas_w - self._step] if bezier[0][2][1] > y_center: # if first point is on the bottom the second will be on the over the center y_range = [self._step, y_center] else: y_range = [y_center, canvas_h - self._step] bezier[1][2] = Vector2(random.randrange(*x_range), random.randrange(*y_range)) # second line end bezier[1][3] = Vector2(ex.rand_safe_curve(bezier[1][2], canvas_w, canvas_h)) # line 3 start bezier[2][0] = bezier[1][2] bezier[2][1] = bezier[1][2] + Vector2(-(Vector2.from_points(bezier[1][2], bezier[1][3]))) # 5th point modifier # line 3 end bezier[2][2] = Vector2(self.end_positions[i]) # last point bezier[2][3] = Vector2(random.randrange(self._step, canvas_w - self._step), random.randrange(self._step, self._step * (data[3] - 1))) # 6th point modifier bezier_points = [] for j in range(3): bezier_points.extend(ex.DrawBezier(bezier[j])) self.ready_lines.append(bezier_points)