mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Add family option to match_style
This commit is contained in:
parent
4a71577bcc
commit
da792ef2d9
1 changed files with 11 additions and 10 deletions
|
@ -158,21 +158,22 @@ class VMobject(Mobject):
|
||||||
self.set_stroke(color, family=family)
|
self.set_stroke(color, family=family)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def match_style(self, vmobject):
|
def match_style(self, vmobject, family=True):
|
||||||
for a_name in ["fill_rgbas", "stroke_rgbas", "background_stroke_rgbas"]:
|
for a_name in ["fill_rgbas", "stroke_rgbas", "background_stroke_rgbas"]:
|
||||||
setattr(self, a_name, np.array(getattr(vmobject, a_name)))
|
setattr(self, a_name, np.array(getattr(vmobject, a_name)))
|
||||||
self.stroke_width = vmobject.stroke_width
|
self.stroke_width = vmobject.stroke_width
|
||||||
self.background_stroke_width = vmobject.background_stroke_width
|
self.background_stroke_width = vmobject.background_stroke_width
|
||||||
|
|
||||||
# Does its best to match up submobject lists, and
|
if family:
|
||||||
# match styles accordingly
|
# Does its best to match up submobject lists, and
|
||||||
submobs1, submobs2 = self.submobjects, vmobject.submobjects
|
# match styles accordingly
|
||||||
if len(submobs1) == 0:
|
submobs1, submobs2 = self.submobjects, vmobject.submobjects
|
||||||
return self
|
if len(submobs1) == 0:
|
||||||
elif len(submobs2) == 0:
|
return self
|
||||||
submobs2 = [vmobject]
|
elif len(submobs2) == 0:
|
||||||
for sm1, sm2 in zip(*make_even(submobs1, submobs2)):
|
submobs2 = [vmobject]
|
||||||
sm1.match_style(sm2)
|
for sm1, sm2 in zip(*make_even(submobs1, submobs2)):
|
||||||
|
sm1.match_style(sm2)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def fade_no_recurse(self, darkness):
|
def fade_no_recurse(self, darkness):
|
||||||
|
|
Loading…
Add table
Reference in a new issue