當前位置: 首頁>>代碼示例>>Python>>正文


Python VGroup.set_stroke方法代碼示例

本文整理匯總了Python中mobject.vectorized_mobject.VGroup.set_stroke方法的典型用法代碼示例。如果您正苦於以下問題:Python VGroup.set_stroke方法的具體用法?Python VGroup.set_stroke怎麽用?Python VGroup.set_stroke使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mobject.vectorized_mobject.VGroup的用法示例。


在下文中一共展示了VGroup.set_stroke方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_riemann_rectangles

# 需要導入模塊: from mobject.vectorized_mobject import VGroup [as 別名]
# 或者: from mobject.vectorized_mobject.VGroup import set_stroke [as 別名]
    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
開發者ID:crclayton,項目名稱:manim,代碼行數:36,代碼來源:graph_scene.py

示例2: get_riemann_rectangles

# 需要導入模塊: from mobject.vectorized_mobject import VGroup [as 別名]
# 或者: from mobject.vectorized_mobject.VGroup import set_stroke [as 別名]
 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
開發者ID:aquafemi,項目名稱:manim,代碼行數:25,代碼來源:graph_scene.py


注:本文中的mobject.vectorized_mobject.VGroup.set_stroke方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。