mirror of
https://github.com/3b1b/manim.git
synced 2025-08-20 05:14:12 +00:00
Have Arrow track what stroke width it was set to
This commit is contained in:
parent
2cdb85cae9
commit
17cd597904
1 changed files with 5 additions and 2 deletions
|
@ -654,6 +654,7 @@ class Arrow(Line):
|
||||||
self.max_tip_length_to_length_ratio = max_tip_length_to_length_ratio
|
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.max_width_to_length_ratio = max_width_to_length_ratio
|
||||||
self.n_tip_points = 3
|
self.n_tip_points = 3
|
||||||
|
self.original_stroke_width = stroke_width
|
||||||
super().__init__(
|
super().__init__(
|
||||||
start, end,
|
start, end,
|
||||||
stroke_color=stroke_color,
|
stroke_color=stroke_color,
|
||||||
|
@ -695,10 +696,11 @@ class Arrow(Line):
|
||||||
def create_tip_with_stroke_width(self) -> Self:
|
def create_tip_with_stroke_width(self) -> Self:
|
||||||
if self.get_num_points() < 3:
|
if self.get_num_points() < 3:
|
||||||
return self
|
return self
|
||||||
tip_width = self.tip_width_ratio * min(
|
stroke_width = min(
|
||||||
float(self.get_stroke_width()),
|
self.original_stroke_width,
|
||||||
self.max_width_to_length_ratio * self.get_length(),
|
self.max_width_to_length_ratio * self.get_length(),
|
||||||
)
|
)
|
||||||
|
tip_width = self.tip_width_ratio * stroke_width
|
||||||
ntp = self.n_tip_points
|
ntp = self.n_tip_points
|
||||||
self.data['stroke_width'][:-ntp] = self.data['stroke_width'][0]
|
self.data['stroke_width'][:-ntp] = self.data['stroke_width'][0]
|
||||||
self.data['stroke_width'][-ntp:, 0] = tip_width * np.linspace(1, 0, ntp)
|
self.data['stroke_width'][-ntp:, 0] = tip_width * np.linspace(1, 0, ntp)
|
||||||
|
@ -718,6 +720,7 @@ class Arrow(Line):
|
||||||
*args, **kwargs
|
*args, **kwargs
|
||||||
) -> Self:
|
) -> Self:
|
||||||
super().set_stroke(color=color, width=width, *args, **kwargs)
|
super().set_stroke(color=color, width=width, *args, **kwargs)
|
||||||
|
self.original_stroke_width = self.get_stroke_width()
|
||||||
if self.has_points():
|
if self.has_points():
|
||||||
self.reset_tip()
|
self.reset_tip()
|
||||||
return self
|
return self
|
||||||
|
|
Loading…
Add table
Reference in a new issue