mirror of
https://github.com/3b1b/manim.git
synced 2025-09-19 04:41:56 +00:00
Ensure positive orientation on all SVG, not just PathStrings
This commit is contained in:
parent
1bd6a77151
commit
ab57b0acf0
2 changed files with 7 additions and 4 deletions
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue