def get_curve(self, spline, matrix): segments = [] pairs = zip(spline.bezier_points, spline.bezier_points[1:]) if spline.use_cyclic_u: pairs = list(pairs) + [ (spline.bezier_points[-1], spline.bezier_points[0]) ] points = [] is_first = True for p1, p2 in pairs: c0 = p1.co c1 = p1.handle_right c2 = p2.handle_left c3 = p2.co if self.apply_matrix: c0, c1, c2, c3 = [tuple(matrix @ c) for c in [c0, c1, c2, c3]] else: c0, c1, c2, c3 = [tuple(c) for c in [c0, c1, c2, c3]] points.append([c0, c1, c2, c3]) segment = SvCubicBezierCurve(c0, c1, c2, c3) segments.append(segment) if self.concat_segments: return points, concatenate_curves(segments) else: return points, segments
def to_bezier_segments(self): control_points = self.spline.get_control_points() is_cubic = isinstance(self.spline, CubicSpline) curve_constructor = lambda cs: SvCubicBezierCurve( *cs) if is_cubic else SvBezierCurve segments = [curve_constructor(points) for points in control_points] return segments