Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions manim/animation/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from collections.abc import Iterable, Sequence
from copy import deepcopy
from functools import partialmethod
from typing import TYPE_CHECKING, Callable

from typing_extensions import Self
Expand Down Expand Up @@ -479,6 +480,52 @@ def is_introducer(self) -> bool:
"""
return self.introducer

@classmethod
def __init_subclass__(cls, **kwargs) -> None:
super().__init_subclass__(**kwargs)

cls._original__init__ = cls.__init__

@classmethod
def set_default(cls, **kwargs) -> None:
"""Sets the default values of keyword arguments.

If this method is called without any additional keyword
arguments, the original default values of the initialization
method of this class are restored.

Parameters
----------

kwargs
Passing any keyword argument will update the default
values of the keyword arguments of the initialization
function of this class.

Examples
--------

.. manim:: ChangeDefaultAnimation

class ChangeDefaultAnimation(Scene):
def construct(self):
Rotate.set_default(run_time=2,rate_func=rate_functions.linear)
Indicate.set_default(color=None)

S = Square(color=BLUE,fill_color=BLUE,fill_opacity=0.25)
self.add(S)
self.play(Rotate(S,PI))
self.play(Indicate(S))

Rotate.set_default()
Indicate.set_default()

"""
if kwargs:
cls.__init__ = partialmethod(cls.__init__, **kwargs)
else:
cls.__init__ = cls._original__init__


def prepare_animation(
anim: Animation | mobject._AnimationBuilder,
Expand Down