Skip to content

Overridden add operations for mobjects#1667

Merged
3b1b merged 16 commits into3b1b:masterfrom
TurkeyBilly:master
Nov 1, 2021
Merged

Overridden add operations for mobjects#1667
3b1b merged 16 commits into3b1b:masterfrom
TurkeyBilly:master

Conversation

@TurkeyBilly
Copy link
Contributor

Motivation

  • To make combining mobjects to a Group of mobjects and adding mobjects to a group more convenient.

Proposed changes

  • In file mobject.py, added add function and mul dunder function for Mobject, returning a Group type accordingly
  • In file vectorized_mobject,py, added add dunder function

Test

Code:

class testscene(Scene):
    def construct(self):
        cir = Circle()
        sq = Square()
        group1 = (cir*6).arrange_in_grid(2, 3)
        print(type(group1))
        self.add(group1)
        group2 = (cir+sq).move_to(DOWN)
        self.add(group2)
        print(type(group2))

Result:

<class 'manimlib.mobject.types.vectorized_mobject.VGroup'>
<class 'manimlib.mobject.types.vectorized_mobject.VGroup'>

@TonyCrane TonyCrane requested a review from 3b1b November 1, 2021 04:01
Copy link
Owner

@3b1b 3b1b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just one minor tweak.

Small bug fix to Mobject.__add__
@3b1b 3b1b merged commit 5a0e5a1 into 3b1b:master Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants