Skip to content

Commit 4190072

Browse files
Modify DashedVMobject to have an even dash pattern for closed shapes. (#884)
* DashedVMobject fix for closed shapes. Added fix to give even dash patterns to closed objects inside a `DashedVMobject`. * Formatted with black, sorry, forgot to do that! * Update manim/mobject/types/vectorized_mobject.py Co-authored-by: Leo Torres <[email protected]> Co-authored-by: Leo Torres <[email protected]>
1 parent f42bd05 commit 4190072

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

manim/mobject/types/vectorized_mobject.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1500,9 +1500,16 @@ def __init__(
15001500
full_d_alpha = 1.0 / num_dashes
15011501
partial_d_alpha = full_d_alpha * ps_ratio
15021502

1503+
# Shifts the alphas and removes the last dash
1504+
# to give closed shapes even spacing
1505+
if vmobject.is_closed():
1506+
alphas += partial_d_alpha / 2
1507+
np.delete(alphas, -1)
1508+
15031509
# Rescale so that the last point of vmobject will
15041510
# be the end of the last dash
1505-
alphas /= 1 - full_d_alpha + partial_d_alpha
1511+
else:
1512+
alphas /= 1 - full_d_alpha + partial_d_alpha
15061513

15071514
self.add(
15081515
*[

0 commit comments

Comments
 (0)