mirror of
https://github.com/3b1b/manim.git
synced 2025-07-30 21:44:19 +08:00
Made Mobject.copy somewhat lighter-weight
This commit is contained in:
@ -1,8 +1,8 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import operator as op
|
import operator as op
|
||||||
import os
|
import os
|
||||||
|
import copy
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from copy import deepcopy
|
|
||||||
from colour import Color
|
from colour import Color
|
||||||
|
|
||||||
from helpers import *
|
from helpers import *
|
||||||
@ -97,7 +97,15 @@ class Mobject(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
return deepcopy(self)
|
copy_mobject = copy.copy(self)
|
||||||
|
copy_mobject.points = np.array(self.points)
|
||||||
|
copy_mobject.submobjects = [
|
||||||
|
submob.copy() for submob in self.submobjects
|
||||||
|
]
|
||||||
|
return copy_mobject
|
||||||
|
|
||||||
|
def deepcopy(self):
|
||||||
|
return copy.deepcopy(self)
|
||||||
|
|
||||||
def generate_target(self):
|
def generate_target(self):
|
||||||
self.target = None #Prevent exponential explosion
|
self.target = None #Prevent exponential explosion
|
||||||
|
@ -200,9 +200,7 @@ class VMobject(Mobject):
|
|||||||
but will be tracked in a separate special list for when
|
but will be tracked in a separate special list for when
|
||||||
it comes time to display.
|
it comes time to display.
|
||||||
"""
|
"""
|
||||||
subpath_mobject = self.copy()#TODO, better way?
|
subpath_mobject = VMobject()
|
||||||
subpath_mobject.submobjects = []
|
|
||||||
# subpath_mobject = self.__class__()
|
|
||||||
subpath_mobject.is_subpath = True
|
subpath_mobject.is_subpath = True
|
||||||
subpath_mobject.set_points(points)
|
subpath_mobject.set_points(points)
|
||||||
self.add(subpath_mobject)
|
self.add(subpath_mobject)
|
||||||
|
Reference in New Issue
Block a user