コード例 #1
0
ファイル: vectorized_mobject.py プロジェクト: praduca/manim
 def change_anchor_mode(self, mode: str):
     assert(mode in ("jagged", "approx_smooth", "true_smooth"))
     nppc = self.n_points_per_curve
     for submob in self.family_members_with_points():
         subpaths = submob.get_subpaths()
         submob.clear_points()
         for subpath in subpaths:
             anchors = np.vstack([subpath[::nppc], subpath[-1:]])
             new_subpath = np.array(subpath)
             if mode == "approx_smooth":
                 new_subpath[1::nppc] = get_smooth_quadratic_bezier_handle_points(anchors)
             elif mode == "true_smooth":
                 h1, h2 = get_smooth_cubic_bezier_handle_points(anchors)
                 new_subpath = get_quadratic_approximation_of_cubic(anchors[:-1], h1, h2, anchors[1:])
             elif mode == "jagged":
                 new_subpath[1::nppc] = 0.5 * (anchors[:-1] + anchors[1:])
             submob.append_points(new_subpath)
         submob.refresh_triangulation()
     return self
コード例 #2
0
 def change_anchor_mode(self, mode):
     assert (mode in ["jagged", "smooth"])
     nppc = self.n_points_per_curve
     for submob in self.family_members_with_points():
         subpaths = submob.get_subpaths()
         submob.clear_points()
         for subpath in subpaths:
             anchors = np.vstack([subpath[::nppc], subpath[-1:]])
             new_subpath = np.array(subpath)
             if mode == "smooth":
                 # TOOD, it's not clear which of the two options below should be the default,
                 # leaving option 1 here commented out as a temporary note.
                 # Option 1:
                 # new_subpath[1::nppc] = get_smooth_quadratic_bezier_handle_points(anchors)
                 # Option 2:
                 h1, h2 = get_smooth_cubic_bezier_handle_points(anchors)
                 new_subpath = get_quadratic_approximation_of_cubic(
                     anchors[:-1], h1, h2, anchors[1:])
             elif mode == "jagged":
                 new_subpath[1::nppc] = 0.5 * (anchors[:-1] + anchors[1:])
             submob.append_points(new_subpath)
         submob.refresh_triangulation()
     return self