Skip to content

Commit

Permalink
Have Arrow track what stroke width it was set to
Browse files Browse the repository at this point in the history
  • Loading branch information
3b1b committed Nov 6, 2023
1 parent 2cdb85c commit 17cd597
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions manimlib/mobject/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ def __init__(
self.max_tip_length_to_length_ratio = max_tip_length_to_length_ratio
self.max_width_to_length_ratio = max_width_to_length_ratio
self.n_tip_points = 3
self.original_stroke_width = stroke_width
super().__init__(
start, end,
stroke_color=stroke_color,
Expand Down Expand Up @@ -695,10 +696,11 @@ def insert_tip_anchor(self) -> Self:
def create_tip_with_stroke_width(self) -> Self:
if self.get_num_points() < 3:
return self
tip_width = self.tip_width_ratio * min(
float(self.get_stroke_width()),
stroke_width = min(
self.original_stroke_width,
self.max_width_to_length_ratio * self.get_length(),
)
tip_width = self.tip_width_ratio * stroke_width
ntp = self.n_tip_points
self.data['stroke_width'][:-ntp] = self.data['stroke_width'][0]
self.data['stroke_width'][-ntp:, 0] = tip_width * np.linspace(1, 0, ntp)
Expand All @@ -718,6 +720,7 @@ def set_stroke(
*args, **kwargs
) -> Self:
super().set_stroke(color=color, width=width, *args, **kwargs)
self.original_stroke_width = self.get_stroke_width()
if self.has_points():
self.reset_tip()
return self
Expand Down

0 comments on commit 17cd597

Please sign in to comment.