def __init__(self, expression, **kwargs): digest_config(self, kwargs, locals()) self.is_input_a_list = isinstance(expression, list) VMobject.__init__(self, **kwargs) self.move_into_position() if self.organize_left_to_right: self.organize_submobjects_left_to_right()
def __init__(self, *args, **kwargs): digest_config(self, kwargs, locals()) ##TODO, Eventually remove this if len(args) == 1 and isinstance(args[0], list): self.args = args[0] ## assert (all([isinstance(a, str) for a in self.args])) self.tex_string = self.get_modified_expression() VMobject.__init__(self, **kwargs) self.move_into_position() if self.organize_left_to_right: self.organize_submobjects_left_to_right()
def __init__(self, *args, **kwargs): digest_config(self, kwargs, locals()) ##TODO, Eventually remove this if len(args) == 1 and isinstance(args[0], list): self.args = args[0] ## assert(all([isinstance(a, str) for a in self.args])) self.tex_string = self.get_modified_expression() VMobject.__init__(self, **kwargs) self.move_into_position() if self.organize_left_to_right: self.organize_submobjects_left_to_right()
def add_background_rectangle(self, color=BLACK, opacity=0.75): self.background_rectangle = BackgroundRectangle(self, color=color, fill_opacity=opacity) letters = VMobject(*self.submobjects) self.submobjects = [self.background_rectangle, letters] return self
def get_mobjects_from(self, element): result = [] if not isinstance(element, minidom.Element): return result if element.tagName == 'defs': self.update_ref_to_element(element) elif element.tagName == 'style': pass #TODO, handle style elif element.tagName in ['g', 'svg']: result += it.chain(*[ self.get_mobjects_from(child) for child in element.childNodes ]) elif element.tagName == 'path': result.append( self.path_string_to_mobject(element.getAttribute('d'))) elif element.tagName == 'use': result += self.use_to_mobjects(element) elif element.tagName == 'rect': result.append(self.rect_to_mobject(element)) elif element.tagName == 'circle': result.append(self.circle_to_mobject(element)) elif element.tagName == 'ellipse': result.append(self.ellipse_to_mobject(element)) elif element.tagName in ['polygon', 'polyline']: result.append(self.polygon_to_mobject(element)) else: pass ##TODO # warnings.warn("Unknown element type: " + element.tagName) result = filter(lambda m: m is not None, result) self.handle_transforms(element, VMobject(*result)) if len(result) > 1 and not self.unpack_groups: result = [VGroup(*result)] return result
def use_to_mobjects(self, use_element): #Remove initial "#" character ref = use_element.getAttribute("xlink:href")[1:] if ref not in self.ref_to_element: warnings.warn("%s not recognized" % ref) return VMobject() return self.get_mobjects_from(self.ref_to_element[ref])
def handle_multiple_args(self): new_submobjects = [] curr_index = 0 self.expression_parts = list(self.args) for expr in self.args: model = TexMobject(expr, **self.CONFIG) new_index = curr_index + len(model.submobjects) new_submobjects.append( VMobject(*self.submobjects[curr_index:new_index])) curr_index = new_index self.submobjects = new_submobjects return self
def g_to_mobjects(self, g_element): mob = VMobject(*self.get_mobjects_from(g_element)) self.handle_transforms(g_element, mob) return mob.submobjects
def __init__(self, **kwargs): digest_config(self, kwargs, locals()) self.ensure_valid_file() VMobject.__init__(self, **kwargs) self.move_into_position()
def __init__(self, path_string, **kwargs): digest_locals(self) VMobject.__init__(self, **kwargs)
def __init__(self, svg_file, **kwargs): digest_config(self, kwargs, locals()) VMobject.__init__(self, **kwargs) self.move_into_position()
def __init__(self, expression, **kwargs): digest_config(self, kwargs, locals()) VMobject.__init__(self, **kwargs) self.move_into_position() self.organize_submobjects()