본문 바로가기

분류 전체보기

(284)
[032]Axes axes = Axes() class AxesTest(Scene): def construct(self): self.c2p_test() def c2p_test(self): axes = Axes( x_min=-10, x_max=10, y_min=-100, y_max=100, number_line_config={ "tick_size": 0.05, }, x_axis_config={ "unit_size": 0.5, "tick_frequency": 2, "include_numbers": True, "numbers_to_show": np.append(np.arange(-10,0,2),np.arange(2,10,2)), }, y_axis_config={ "unit_size": 6/200, "tick_frequency":..
[031]NumberLine unit_size = 1 n_line = NumberLine( x_min=-5, x_max=5, unit_size=1, include_numbers=True, tick_frequency=1, ) self.add(n_line) self.wait() unit_size = 0.1 n_line = NumberLine( x_min=-50, x_max=50, tick_frequency=10, unit_size=0.1, include_numbers=True, numbers_to_show=np.arange(-50,50.1,10), ) leftmost_tick n_line = NumberLine( x_min=-50, x_max=50, tick_frequency=10, tick_size = 0.05, unit_size=0..
[030]FunctionGraph class FrunctionGraphTest(MovingCameraScene): def construct(self): self.add(NumberPlane()) def simple_func(self): graph = FunctionGraph( lambda x: 0.5 * x + 1, x_min = -5, x_max = 5, color = YELLOW, stroke_width = 6, ) self.play(ShowCreation(graph)) def sine_curve(self): curve = FunctionGraph( lambda t: np.sin(t), x_min=-TAU, x_max=TAU, color=YELLOW, stroke_width=6, ) curve.move_to(DR) curve.set_..
[029]ParametricFunction class ParametricFunctionTest(Scene): def construct(self): self.add(NumberPlane()) self.para_function1() def para_function1(self): func1 = lambda t: np.array([t, 0.5 * t,0]) func2 = lambda t: np.array([t, 0.4*(t+3)*(t-2), 0]) graph1 = ParametricFunction( func1, t_min=-4, t_max=4, color=YELLOW, ) graph2 = ParametricFunction( func2, t_min=-4, t_max=4, color=YELLOW, ) # self.add(graph1, graph2) self..
[028]Decimal num_decimal_places num = DecimalNumber(n, num_decimal_places=3) include_sign num = DecimalNumber(n, include_sign=True) group_with_commas num = DecimalNumber(n) num = DecimalNumber(n, group_with_commas=False) show_ellipsis num=DecimalNumber(n, show_ellipsis=True) unit n=99.1 num=DecimalNumber(n, unit="\\%") num=DecimalNumber(n, unit="^\\%") include_background_rectangle rect = Rectangle(fill_opaci..
[027]Ellipse/Annulus/AnnularSector/Sector Ellipse ellipse = Ellipse() Annulus annulus = Annulus() AnnularSector a_sector = AnnularSector() Sector sector = Sector()
[026]Circle def circle_test(self): circle1 = Circle( radius=1, stroke_width=6, stroke_color=RED, fill_opacity=1.0, fill_color=BLUE) circle2 = circle1.copy() circle2.set_fill(color=RED,opacity=1.0) circle1.to_edge(LEFT) circle2.to_edge(RIGHT) self.add(circle1) self.play( Transform(circle1,circle2), run_time=4, ) self.wait()
[025]ArcBetweenPoints def arc_between_test1(self): values = [PI/8, PI/4, PI/2, PI, 3*PI/2] strs = ["PI/8", "PI/4", "PI/2", "PI", "3*PI/2"] def get_arc_text(str, angle_value): arc = ArcBetweenPoints(LEFT, RIGHT, angle=angle_value) num = Text(str, size=0.35, stroke_width=0).next_to(arc,UP) return VGroup(arc,num) arcs = VGroup(*[get_arc_text(str,angle_value) for str, angle_value in zip(strs,values)]) arcs.arrange(RIGHT)..
[024]Arc Class Structure Arc Class arc = Arc()
[023]Rectangle, Square, RoundedRectangle Rectangle rect = Rectangle() Square square = Square() RoundedRectangle rect = RoundedRectangle() corner_radius def round_test(self): values = [0.1, 0.5,1,1.5,2] def get_rect(val): rect = RoundedRectangle(corner_radius=val).scale(0.5) text = Text(str(val), size=0.3, stroke_width=0).next_to(rect, UP) return VGroup(rect,text) rects = VGroup(*[get_rect(v) for v in values]) rects.arrange(RIGHT) self...