示例#1
0
 def parabolic_trajectory_to_listener(self, remote_angle):
     remote = DirectionalVector(remote_angle, self.ROOM_RADIUS)
     midpoint_angle = remote_angle + random.choice([1, -1]) * random.uniform(self.MIN_CURVATURE, self.MAX_CURVATURE)
     midpoint = DirectionalVector(midpoint_angle, self.ROOM_RADIUS / 2)
     local = self.LISTENER_POSITION + DirectionalVector(remote_angle, self.NEAREST_DISTANCE_TO_LISTENER)
     control_points = [(remote.x, remote.y), (midpoint.x, midpoint.y), (local.x, local.y)]
     bezier = make_bezier(control_points)
     return bezier(self.TRAJECTORY_PRECISION)
示例#2
0
def draw_bezier(xyz, thick, col, draw):
    if len(xyz) > 2:
        ts = [t / 100.0 for t in range(101)]
        bz = bezier.make_bezier(xyz)
        points = bz(ts)
        for p in range(len(points) - 1):
            draw.line([points[p], points[p + 1]], fill=col, width=thick)
    else:
        draw.line([xyz[0], xyz[1]], fill=col, width=thick)
示例#3
0
 def draw_shrinking_curve(self, x1, y1, x2, y2):
     control_points = [
         Vector2d(x1, y1),
         Vector2d(x1 + (x2 - x1) * 0.3, y1),
         Vector2d(x1 + (x2 - x1) * 0.7, y2),
         Vector2d(x2, y2)
         ]
     bezier = make_bezier([(p.x, p.y) for p in control_points])
     stroke_points = bezier(CURVE_PRECISION)
     self._draw_shrinking_path_xy(stroke_points)
示例#4
0
 def curve_to_file(self):
     control_points = []
     branching_position = self.peer.smoothed_branching_position.value()
     for i in range(CONTROL_POINTS_BEFORE_BRANCH):
         r = float(i) / (CONTROL_POINTS_BEFORE_BRANCH - 1)
         control_points.append(self.peer.departure_position * (1 - r) + branching_position * r)
     target = self.branch_file_crossing()
     control_points.append(target)
     bezier = make_bezier([(p.x, p.y) for p in control_points])
     return bezier(CURVE_PRECISION_TO_FILE)
示例#5
0
def draw_bezier_paths(mosaic):
    from bezier import make_bezier
    ts = [t / 100.0 for t in range(101)]
    for tessera in mosaic.tesserae:
        for path in tessera.paths:
            bezier = make_bezier([
                path[0],
                (tessera.center_x, tessera.center_y),
                path[1],
            ])
            draw.line(bezier(ts), fill=path_color, width=2)
 def draw_curve(self, x1, y1, x2, y2):
     control_points = [
         Vector2d(x1, y1),
         Vector2d(x1 + (x2 - x1) * 0.3, y1),
         Vector2d(x1 + (x2 - x1) * 0.7, y2),
         Vector2d(x2, y2)
         ]
     bezier = make_bezier([(p.x, p.y) for p in control_points])
     points = bezier(CURVE_PRECISION)
     glBegin(GL_LINE_STRIP)
     for x, y in points:
         glVertex2f(x, y)
     glEnd()
示例#7
0
 def draw_curve(self, target):
     points = []
     branching_position = self.smoothed_branching_position.value()
     for i in range(15):
         points.append(self.departure_position * (1-i/14.0)+
                       branching_position * i/14.0)
     points.append(target)
     bezier = make_bezier([(p.x, p.y) for p in points])
     points = bezier([t/50.0 for t in range(51)])
     glBegin(GL_LINE_STRIP)
     for x,y in points:
         glVertex2f(x, y)
     glEnd()
示例#8
0
 def draw_curve(self):
     points = [self.begin_position]
     points.extend(self.mid_points)
     points.append(self.end_position)
     bezier = make_bezier([(p.x, p.y) for p in points])
     points = bezier([t / 50.0 for t in range(51)])
     opacity = 0.5
     glColor3f(1 - opacity, 1 - opacity, 1 - opacity)
     glLineWidth(2.0)
     glBegin(GL_LINE_STRIP)
     for x, y in points:
         glVertex2f(x, y)
     glEnd()
示例#9
0
 def curve(self):
     control_points = []
     branching_position = self.peer.smoothed_branching_position.value()
     for i in range(CONTROL_POINTS_BEFORE_BRANCH):
         r = float(i) / (CONTROL_POINTS_BEFORE_BRANCH-1)
         control_points.append(self.peer.departure_position * (1-r) +
                              branching_position * r)
     if self.is_playing():
         target = self.target_position()
     else:
         target = branching_position + (self.target_position() - branching_position) * \
             (1 - pow(self.decay_time(), 0.3))
     control_points.append(target)
     bezier = make_bezier([(p.x, p.y) for p in control_points])
     return bezier(CURVE_PRECISION)