본문 바로가기

Programming/Manim code

[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.1,
            include_numbers=True,
            numbers_to_show=np.arange(-45,50,10),
            leftmost_tick = -45,
        )

 

 


include_tip=True

 

 


decimal_number_config

 

    decimal_number_config= {
                "num_decimal_places": 1,
    }

 

 


number_to_point

 

    def number_to_point_test(self):
        n_line = NumberLine(
            x_min=-50, x_max=50,
            tick_frequency=10,
            tick_size=0.05,
            unit_size=0.1,
            include_numbers=True,
            numbers_to_show=np.arange(-50,51,10),
        )

        self.add(n_line)
        self.wait()

        tracker = ValueTracker(-50)
        def get_line_obj():
            sp = n_line.number_to_point(tracker.get_value())
            ep = sp + UP*1.5
            arrow = Arrow(sp,ep,buff=0,color=RED)

            num = DecimalNumber(tracker.get_value(), color=RED)
            num.next_to(arrow, UP)
            return VGroup(arrow, num)

        obj = always_redraw(get_line_obj)
        self.add(obj)
        self.play(
            tracker.set_value, 50,
            run_time=5,
        )
        self.wait()

 

 

 


 

반응형

'Programming > Manim code' 카테고리의 다른 글

[33]NumberPlane  (0) 2020.05.12
[032]Axes  (0) 2020.05.11
[030]FunctionGraph  (0) 2020.05.11
[029]ParametricFunction  (0) 2020.05.11
[028]Decimal  (0) 2020.05.11