Ensure positive orientation on all SVG, not just PathStrings

This commit is contained in:
Grant Sanderson 2023-01-26 21:00:07 -08:00
parent 1bd6a77151
commit ab57b0acf0
2 changed files with 7 additions and 4 deletions

View file

@ -74,6 +74,7 @@ class SVGMobject(VMobject):
super().__init__(**kwargs )
self.init_svg_mobject()
self.ensure_positive_orientation()
# Rather than passing style into super().__init__
# do it after svg has been taken in
@ -320,10 +321,6 @@ class VMobjectFromSVGPath(VMobject):
self.set_points(self.get_points_without_null_curves())
# So triangulation doesn't get messed up
self.subdivide_intersections()
# Always default to orienting outward, account
# for the fact that this will get flipped in SVG.__init__
if self.get_unit_normal()[2] > 0:
self.reverse_points()
# Save for future use
PATH_TO_POINTS[path_string] = self.get_points().copy()
else:

View file

@ -827,6 +827,12 @@ class VMobject(Mobject):
)
return normal
def ensure_positive_orientation(self, recurse=True):
for mob in self.get_family(recurse):
if mob.get_unit_normal()[2] < 0:
mob.reverse_points()
return self
# Alignment
def align_points(self, vmobject: VMobject):
winding = self._use_winding_fill and vmobject._use_winding_fill