mirror of
https://github.com/3b1b/manim.git
synced 2025-07-30 05:24:22 +08:00
Fixed deepcopy segfault issue with Camera
This commit is contained in:
@ -5,6 +5,7 @@ import os
|
|||||||
from PIL import Image
|
from PIL import Image
|
||||||
from colour import Color
|
from colour import Color
|
||||||
import aggdraw
|
import aggdraw
|
||||||
|
import copy
|
||||||
|
|
||||||
from helpers import *
|
from helpers import *
|
||||||
from mobject import Mobject, PMobject, VMobject, \
|
from mobject import Mobject, PMobject, VMobject, \
|
||||||
@ -45,6 +46,13 @@ class Camera(object):
|
|||||||
self.resize_space_shape()
|
self.resize_space_shape()
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
|
def __deepcopy__(self, memo):
|
||||||
|
# This is to address a strange bug where deepcopying
|
||||||
|
# will result in a segfault, which is somehow related
|
||||||
|
# to the aggdraw library
|
||||||
|
self.canvas = None
|
||||||
|
return copy.copy(self)
|
||||||
|
|
||||||
def resize_space_shape(self, fixed_dimension = 0):
|
def resize_space_shape(self, fixed_dimension = 0):
|
||||||
"""
|
"""
|
||||||
Changes space_shape to match the aspect ratio
|
Changes space_shape to match the aspect ratio
|
||||||
@ -205,7 +213,7 @@ class Camera(object):
|
|||||||
## Methods associated with svg rendering
|
## Methods associated with svg rendering
|
||||||
|
|
||||||
def get_aggdraw_canvas(self):
|
def get_aggdraw_canvas(self):
|
||||||
if not hasattr(self, "canvas"):
|
if not hasattr(self, "canvas") or not self.canvas:
|
||||||
self.reset_aggdraw_canvas()
|
self.reset_aggdraw_canvas()
|
||||||
return self.canvas
|
return self.canvas
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user