コード例 #1
0
ファイル: objects.py プロジェクト: sptj/manim
class PartyHat(SVGMobject):
    CONFIG = {
        "file_name": "party_hat",
        "height": 1.5,
        "pi_creature": None,
        "stroke_width": 0,
        "fill_opacity": 1,
        "propogate_style_to_family": True,
        "frills_colors": [MAROON_B, PURPLE],
        "cone_color": GREEN,
        "dots_colors": [YELLOW],
    }
    NUM_FRILLS = 7
    NUM_DOTS = 6

    def __init__(self, **kwargs):
        SVGMobject.__init__(self, **kwargs)
        self.scale_to_fit_height(self.height)
        if self.pi_creature is not None:
            self.next_to(self.pi_creature.eyes, UP, buff=0)

        self.frills = VGroup(*self[:self.NUM_FRILLS])
        self.cone = self[self.NUM_FRILLS]
        self.dots = VGroup(*self[self.NUM_FRILLS + 1:])

        self.frills.gradient_highlight(*self.frills_colors)
        self.cone.highlight(self.cone_color)
        self.dots.gradient_highlight(*self.dots_colors)
コード例 #2
0
ファイル: graph_scene.py プロジェクト: crclayton/manim
    def get_riemann_rectangles(
        self, 
        graph,
        x_min = None, 
        x_max = None, 
        dx = 0.1, 
        input_sample_type = "left",
        stroke_width = 1,
        start_color = BLUE,
        end_color = GREEN):
        x_min = x_min if x_min is not None else self.x_min
        x_max = x_max if x_max is not None else self.x_max
        rectangles = VGroup()
        for x in np.arange(x_min, x_max, dx):
            if input_sample_type == "left":
                sample_input = x
            elif input_sample_type == "right":
                sample_input = x+dx
            else:
                raise Exception("Invalid input sample type")
            graph_point = self.input_to_graph_point(sample_input, graph)
            points = VGroup(*map(VectorizedPoint, [
                self.coords_to_point(x, 0),
                self.coords_to_point(x+dx, 0),
                graph_point
            ]))

            rect = Rectangle()
            rect.replace(points, stretch = True)
            rect.set_fill(opacity = 1)
            rectangles.add(rect)
        rectangles.gradient_highlight(start_color, end_color)
        rectangles.set_stroke(BLACK, width = stroke_width)
        return rectangles
コード例 #3
0
ファイル: objects.py プロジェクト: crclayton/manim
class PartyHat(SVGMobject):
    CONFIG = {
        "file_name" : "party_hat",
        "height" : 1.5,
        "pi_creature" : None,
        "stroke_width" : 0,
        "fill_opacity" : 1,
        "propogate_style_to_family" : True,
        "frills_colors" : [MAROON_B, PURPLE],
        "cone_color" : GREEN,
        "dots_colors" : [YELLOW],
    }
    NUM_FRILLS = 7
    NUM_DOTS = 6
    def __init__(self, **kwargs):
        SVGMobject.__init__(self, **kwargs)
        self.scale_to_fit_height(self.height)
        if self.pi_creature is not None:
            self.next_to(self.pi_creature.eyes, UP, buff = 0)

        self.frills = VGroup(*self[:self.NUM_FRILLS])
        self.cone = self[self.NUM_FRILLS]
        self.dots = VGroup(*self[self.NUM_FRILLS+1:])

        self.frills.gradient_highlight(*self.frills_colors)
        self.cone.highlight(self.cone_color)
        self.dots.gradient_highlight(*self.dots_colors)
コード例 #4
0
ファイル: graph_scene.py プロジェクト: snowdj/manim
 def get_riemann_rectangles(self,
                            x_min=None,
                            x_max=None,
                            dx=0.1,
                            stroke_width=1,
                            start_color=BLUE,
                            end_color=GREEN):
     assert (hasattr(self, "func"))
     x_min = x_min if x_min is not None else self.x_min
     x_max = x_max if x_max is not None else self.x_max
     rectangles = VGroup()
     for x in np.arange(x_min, x_max, dx):
         points = VGroup(*map(VectorizedPoint, [
             self.coords_to_point(x, 0),
             self.coords_to_point(x + dx, self.func(x + dx)),
         ]))
         rect = Rectangle()
         rect.replace(points, stretch=True)
         rect.set_fill(opacity=1)
         rectangles.add(rect)
     rectangles.gradient_highlight(start_color, end_color)
     rectangles.set_stroke(BLACK, width=stroke_width)
     return rectangles
コード例 #5
0
ファイル: graph_scene.py プロジェクト: aquafemi/manim
 def get_riemann_rectangles(self, 
                            x_min = None, 
                            x_max = None, 
                            dx = 0.1, 
                            stroke_width = 1,
                            start_color = BLUE,
                            end_color = GREEN):
     assert(hasattr(self, "func"))
     x_min = x_min if x_min is not None else self.x_min
     x_max = x_max if x_max is not None else self.x_max
     rectangles = VGroup()
     for x in np.arange(x_min, x_max, dx):
         points = VGroup(*map(VectorizedPoint, [
             self.coords_to_point(x, 0),
             self.coords_to_point(x+dx, self.func(x+dx)),
         ]))
         rect = Rectangle()
         rect.replace(points, stretch = True)
         rect.set_fill(opacity = 1)
         rectangles.add(rect)
     rectangles.gradient_highlight(start_color, end_color)
     rectangles.set_stroke(BLACK, width = stroke_width)
     return rectangles
コード例 #6
0
ファイル: probability.py プロジェクト: zhujianing/manim
    def add_bars(self, values):
        buff = float(self.width) / (2*len(values) + 1)
        bars = VGroup()
        for i, value in enumerate(values):
            bar = Rectangle(
                height = (value/self.max_value)*self.height,
                width = buff,
                stroke_width = self.bar_stroke_width,
                fill_opacity = self.bar_fill_opacity,
            )
            bar.move_to((2*i+1)*buff*RIGHT, DOWN+LEFT)
            bars.add(bar)
        bars.gradient_highlight(*self.bar_colors)

        bar_labels = VGroup()
        for bar, name in zip(bars, self.bar_names):
            label = TexMobject(str(name))
            label.scale(self.bar_label_scale_val)
            label.next_to(bar, DOWN, SMALL_BUFF)
            bar_labels.add(label)

        self.add(bars, bar_labels)
        self.bars = bars
        self.bar_labels = bar_labels