コード例 #1
0
ファイル: arithmetic.py プロジェクト: stoeckley/manim
    def update_mobject(self, alpha):
        new_tex = self.tex_list[np.ceil(alpha * len(self.tex_list)) - 1]

        if new_tex != self.curr_tex:
            self.curr_tex = new_tex
            self.mobject = TexMobject(new_tex).shift(self.start_center)
        if not all(self.start_center == self.end_center):
            self.mobject.center().shift((1 - alpha) * self.start_center +
                                        alpha * self.end_center)
コード例 #2
0
ファイル: number_line.py プロジェクト: mherkazandjian/manim
 def get_number_mobjects(self, *numbers):
     #TODO, handle decimals
     if len(numbers) == 0:
         numbers = self.default_numbers_to_display()
     result = []
     for number in numbers:
         mob = TexMobject(str(int(number)))
         vert_scale = 2*self.tick_size/mob.get_height()
         hori_scale = self.tick_frequency*self.unit_length_to_spatial_width/mob.get_width()
         mob.scale(min(vert_scale, hori_scale))
         mob.shift(self.number_to_point(number))
         mob.shift(self.get_vertical_number_offset())
         result.append(mob)
     return result
コード例 #3
0
ファイル: arithmetic.py プロジェクト: Rubixdarcy/manim
    def update_mobject(self, alpha):
        new_tex = self.tex_list[np.ceil(alpha*len(self.tex_list))-1]

        if new_tex != self.curr_tex:
            self.curr_tex = new_tex
            self.mobject = TexMobject(new_tex).shift(self.start_center)
        if not all(self.start_center == self.end_center):
            self.mobject.center().shift(
                (1-alpha)*self.start_center + alpha*self.end_center
            )
コード例 #4
0
ファイル: arithmetic.py プロジェクト: Rubixdarcy/manim
class FlipThroughSymbols(Animation):
    DEFAULT_CONFIG = {
        "start_center" : ORIGIN,
        "end_center" : ORIGIN,
    }
    def __init__(self, tex_list, **kwargs):
        mobject = TexMobject(self.curr_tex).shift(start_center)
        Animation.__init__(self, mobject, **kwargs)

    def update_mobject(self, alpha):
        new_tex = self.tex_list[np.ceil(alpha*len(self.tex_list))-1]

        if new_tex != self.curr_tex:
            self.curr_tex = new_tex
            self.mobject = TexMobject(new_tex).shift(self.start_center)
        if not all(self.start_center == self.end_center):
            self.mobject.center().shift(
                (1-alpha)*self.start_center + alpha*self.end_center
            )
コード例 #5
0
ファイル: arithmetic.py プロジェクト: stoeckley/manim
class FlipThroughSymbols(Animation):
    DEFAULT_CONFIG = {
        "start_center": ORIGIN,
        "end_center": ORIGIN,
    }

    def __init__(self, tex_list, **kwargs):
        mobject = TexMobject(self.curr_tex).shift(start_center)
        Animation.__init__(self, mobject, **kwargs)

    def update_mobject(self, alpha):
        new_tex = self.tex_list[np.ceil(alpha * len(self.tex_list)) - 1]

        if new_tex != self.curr_tex:
            self.curr_tex = new_tex
            self.mobject = TexMobject(new_tex).shift(self.start_center)
        if not all(self.start_center == self.end_center):
            self.mobject.center().shift((1 - alpha) * self.start_center +
                                        alpha * self.end_center)
コード例 #6
0
ファイル: arithmetic.py プロジェクト: stoeckley/manim
 def get_mobs_from_terms(self, start_terms, end_terms, size):
     """
     Need to ensure that all image mobjects for a tex expression
     stemming from the same string are point-for-point copies of one
     and other.  This makes transitions much smoother, and not look
     like point-clouds.
     """
     num_start_terms = len(start_terms)
     all_mobs = np.array(
         TexMobject(start_terms, size = size).split() + \
         TexMobject(end_terms, size = size).split()
     )
     all_terms = np.array(start_terms + end_terms)
     for term in set(all_terms):
         matches = all_terms == term
         if sum(matches) > 1:
             base_mob = all_mobs[list(all_terms).index(term)]
             all_mobs[matches] = [
                 base_mob.copy().replace(target_mob)
                 for target_mob in all_mobs[matches]
             ]
     return all_mobs[:num_start_terms], all_mobs[num_start_terms:]
コード例 #7
0
ファイル: number_line.py プロジェクト: mherkazandjian/manim
 def get_coordinate_labels(self, x_vals = None, y_vals = None):
     result = []
     nudge = 0.1*(DOWN+RIGHT)
     if x_vals == None and y_vals == None:
         x_vals = range(-int(self.x_radius), int(self.x_radius))
         y_vals = range(-int(self.y_radius), int(self.y_radius))
     for index, vals in zip([0, 1], [x_vals, y_vals]):
         num_pair = [0, 0]
         for val in vals:
             num_pair[index] = val
             point = self.num_pair_to_point(num_pair)
             num = TexMobject(str(val))
             num.scale(self.number_scale_factor)
             num.shift(point-num.get_corner(UP+LEFT)+nudge)
             result.append(num)
     return result
コード例 #8
0
ファイル: arithmetic.py プロジェクト: stoeckley/manim
 def __init__(self, tex_list, **kwargs):
     mobject = TexMobject(self.curr_tex).shift(start_center)
     Animation.__init__(self, mobject, **kwargs)