2019-02-09 09:08:57 -08:00
|
|
|
from manimlib.animation.transform import Transform
|
2019-02-09 10:21:14 -08:00
|
|
|
# from manimlib.utils.paths import counterclockwise_path
|
|
|
|
from manimlib.constants import PI
|
2019-02-09 09:08:57 -08:00
|
|
|
|
|
|
|
|
|
|
|
class GrowFromPoint(Transform):
|
|
|
|
CONFIG = {
|
|
|
|
"point_color": None,
|
|
|
|
}
|
|
|
|
|
|
|
|
def __init__(self, mobject, point, **kwargs):
|
2019-02-09 10:21:14 -08:00
|
|
|
self.point = point
|
|
|
|
super().__init__(mobject, **kwargs)
|
|
|
|
|
|
|
|
def create_target(self):
|
|
|
|
return self.mobject
|
|
|
|
|
|
|
|
def create_starting_mobject(self):
|
|
|
|
start = super().create_starting_mobject()
|
|
|
|
start.scale(0)
|
|
|
|
start.move_to(self.point)
|
2019-02-09 09:08:57 -08:00
|
|
|
if self.point_color:
|
2019-02-09 10:21:14 -08:00
|
|
|
start.set_color(self.point_color)
|
|
|
|
return start
|
2019-02-09 09:08:57 -08:00
|
|
|
|
|
|
|
|
|
|
|
class GrowFromCenter(GrowFromPoint):
|
|
|
|
def __init__(self, mobject, **kwargs):
|
2019-02-09 10:21:14 -08:00
|
|
|
point = mobject.get_center()
|
|
|
|
super().__init__(mobject, point, **kwargs)
|
2019-02-09 09:08:57 -08:00
|
|
|
|
|
|
|
|
|
|
|
class GrowFromEdge(GrowFromPoint):
|
|
|
|
def __init__(self, mobject, edge, **kwargs):
|
2020-02-13 10:54:09 -08:00
|
|
|
point = mobject.get_bounding_box_point(edge)
|
2019-02-09 10:21:14 -08:00
|
|
|
super().__init__(mobject, point, **kwargs)
|
2019-02-09 09:08:57 -08:00
|
|
|
|
|
|
|
|
|
|
|
class GrowArrow(GrowFromPoint):
|
|
|
|
def __init__(self, arrow, **kwargs):
|
2019-02-09 10:21:14 -08:00
|
|
|
point = arrow.get_start()
|
|
|
|
super().__init__(arrow, point, **kwargs)
|
2019-02-09 09:08:57 -08:00
|
|
|
|
|
|
|
|
|
|
|
class SpinInFromNothing(GrowFromCenter):
|
|
|
|
CONFIG = {
|
2019-02-09 10:21:14 -08:00
|
|
|
"path_arc": PI,
|
2019-02-09 09:08:57 -08:00
|
|
|
}
|