Change default to flat stroke, except in 3d situations

This commit is contained in:
Grant Sanderson 2024-08-20 11:52:05 -05:00
parent b8931e7b9c
commit 7474ae17b0
5 changed files with 9 additions and 5 deletions

View file

@ -530,6 +530,7 @@ class ThreeDAxes(Axes):
z_axis_config: dict = dict(),
z_normal: Vect3 = DOWN,
depth: float | None = None,
flat_stroke: bool = False,
**kwargs
):
Axes.__init__(self, x_range, y_range, **kwargs)
@ -553,6 +554,7 @@ class ThreeDAxes(Axes):
self.z_axis.shift(self.x_axis.n2p(0))
self.axes.add(self.z_axis)
self.add(self.z_axis)
self.set_flat_stroke(flat_stroke)
def get_all_ranges(self) -> list[Sequence[float]]:
return [self.x_range, self.y_range, self.z_range]

View file

@ -642,7 +642,6 @@ class Arrow(Line):
end: Vect3 | Mobject,
stroke_color: ManimColor = GREY_A,
stroke_width: float = 5,
flat_stroke: bool = True,
buff: float = 0.25,
tip_width_ratio: float = 5,
tip_len_to_width: float = 0.0075,
@ -660,7 +659,6 @@ class Arrow(Line):
start, end,
stroke_color=stroke_color,
stroke_width=stroke_width,
flat_stroke=flat_stroke,
buff=buff,
**kwargs
)

View file

@ -38,6 +38,7 @@ class SurfaceMesh(VGroup):
normal_nudge: float = 1e-2,
depth_test: bool = True,
joint_type: str = 'no_joint',
flat_stroke: bool = False,
**kwargs
):
self.uv_surface = uv_surface
@ -49,6 +50,7 @@ class SurfaceMesh(VGroup):
stroke_width=stroke_width,
depth_test=depth_test,
joint_type=joint_type,
flat_stroke=flat_stroke,
**kwargs
)

View file

@ -90,7 +90,7 @@ class VMobject(Mobject):
long_lines: bool = False,
# Could also be "no_joint", "bevel", "miter"
joint_type: str = "auto",
flat_stroke: bool = False,
flat_stroke: bool = True,
use_simple_quadratic_approx: bool = False,
# Measured in pixel widths
anti_alias_width: float = 1.5,
@ -393,7 +393,7 @@ class VMobject(Mobject):
return self.get_stroke_opacity()
def set_flat_stroke(self, flat_stroke: bool = True, recurse: bool = True) -> Self:
self.set_uniform(recurse, flat_stroke=flat_stroke)
self.set_uniform(recurse, flat_stroke=float(flat_stroke))
return self
def get_flat_stroke(self) -> bool:

View file

@ -1049,8 +1049,10 @@ class ThreeDScene(Scene):
default_frame_orientation = (-30, 70)
always_depth_test = True
def add(self, *mobjects: Mobject, set_depth_test: bool = True):
def add(self, *mobjects: Mobject, set_depth_test: bool = True, perp_stroke: bool = True):
for mob in mobjects:
if set_depth_test and not mob.is_fixed_in_frame() and self.always_depth_test:
mob.apply_depth_test()
if isinstance(mob, VMobject) and mob.has_stroke() and perp_stroke:
mob.set_flat_stroke(False)
super().add(*mobjects)