2121 interpolate ,
2222 partial_quadratic_bezier_points ,
2323 proportions_along_bezier_curve_for_point ,
24+ quadratic_bezier_remap ,
25+ subdivide_quadratic_bezier ,
2426)
2527from manim .utils .color import *
2628from manim .utils .config_ops import _Data
@@ -1281,10 +1283,7 @@ def interpolate(self, mobject1, mobject2, alpha, *args, **kwargs):
12811283 return self
12821284
12831285 def pointwise_become_partial (
1284- self ,
1285- vmobject : OpenGLVMobject ,
1286- a : float ,
1287- b : float ,
1286+ self , vmobject : OpenGLVMobject , a : float , b : float , remap = True
12881287 ) -> OpenGLVMobject :
12891288 """Given two bounds a and b, transforms the points of the self vmobject into the points of the vmobject
12901289 passed as parameter with respect to the bounds. Points here stand for control points of the bezier curves (anchors and handles)
@@ -1297,6 +1296,9 @@ def pointwise_become_partial(
12971296 upper-bound.
12981297 b : float
12991298 lower-bound
1299+ remap : bool
1300+ if the point amount should be kept the same (True)
1301+ This option should be manually set to False if keeping the number of points is not needed
13001302 """
13011303 assert isinstance (vmobject , OpenGLVMobject )
13021304 # Partial curve includes three portions:
@@ -1314,7 +1316,6 @@ def pointwise_become_partial(
13141316 # Ex: if lower_index is 3, and lower_residue is 0.4, then the algorithm will append to the points 0.4 of the third bezier curve
13151317 lower_index , lower_residue = integer_interpolate (0 , num_quadratics , a )
13161318 upper_index , upper_residue = integer_interpolate (0 , num_quadratics , b )
1317-
13181319 self .clear_points ()
13191320 if num_quadratics == 0 :
13201321 return self
@@ -1333,8 +1334,14 @@ def pointwise_become_partial(
13331334 ),
13341335 )
13351336 # TODO: replace by smooth_bezier_remap(triplets[li+1:ui], num_quadratics-2) -> [points; len(ui-li+1)] : #2742
1336- for triplet in bezier_triplets [lower_index + 1 : upper_index ]:
1337- self .append_points (triplet )
1337+ inner_points = bezier_triplets [lower_index + 1 : upper_index ]
1338+
1339+ if remap :
1340+ new_triplets = quadratic_bezier_remap (inner_points , num_quadratics - 2 )
1341+ else :
1342+ new_triplets = bezier_triplets
1343+
1344+ self .append_points (np .asarray (new_triplets ).reshape (- 1 , 3 ))
13381345 self .append_points (
13391346 partial_quadratic_bezier_points (
13401347 bezier_triplets [upper_index ], 0 , upper_residue
0 commit comments