Sets attributes. I.e. ``my_mobject.set(foo=1)`` applies ``my_mobject.foo = 1``. This is a convenience to be used along with :attr:`animate` to animate setting attributes. In addition to this method, there is a compatibility layer that allows ``get_*`` and `
(self, **kwargs)
| 657 | raise NotImplementedError |
| 658 | |
| 659 | def set(self, **kwargs) -> Self: |
| 660 | """Sets attributes. |
| 661 | |
| 662 | I.e. ``my_mobject.set(foo=1)`` applies ``my_mobject.foo = 1``. |
| 663 | |
| 664 | This is a convenience to be used along with :attr:`animate` to |
| 665 | animate setting attributes. |
| 666 | |
| 667 | In addition to this method, there is a compatibility |
| 668 | layer that allows ``get_*`` and ``set_*`` methods to |
| 669 | get and set generic attributes. For instance:: |
| 670 | |
| 671 | >>> mob = Mobject() |
| 672 | >>> mob.set_foo(0) |
| 673 | Mobject |
| 674 | >>> mob.get_foo() |
| 675 | 0 |
| 676 | >>> mob.foo |
| 677 | 0 |
| 678 | |
| 679 | This compatibility layer does not interfere with any |
| 680 | ``get_*`` or ``set_*`` methods that are explicitly |
| 681 | defined. |
| 682 | |
| 683 | .. warning:: |
| 684 | |
| 685 | This compatibility layer is for backwards compatibility |
| 686 | and is not guaranteed to stay around. Where applicable, |
| 687 | please prefer getting/setting attributes normally or with |
| 688 | the :meth:`set` method. |
| 689 | |
| 690 | Parameters |
| 691 | ---------- |
| 692 | **kwargs |
| 693 | The attributes and corresponding values to set. |
| 694 | |
| 695 | Returns |
| 696 | ------- |
| 697 | :class:`Mobject` |
| 698 | ``self`` |
| 699 | |
| 700 | Examples |
| 701 | -------- |
| 702 | :: |
| 703 | |
| 704 | >>> mob = Mobject() |
| 705 | >>> mob.set(foo=0) |
| 706 | Mobject |
| 707 | >>> mob.foo |
| 708 | 0 |
| 709 | """ |
| 710 | for attr, value in kwargs.items(): |
| 711 | setattr(self, attr, value) |
| 712 | |
| 713 | return self |
| 714 | |
| 715 | def __getattr__(self, attr: str) -> types.MethodType: |
| 716 | # Add automatic compatibility layer |