본문 바로가기

Programming/Manim code

[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_opacity=1,fill_color=WHITE)
    n=3.14
    num = DecimalNumber(n, include_background_rectangle=True).move_to(rect)

 

 

edge_to_fix 

    d1 = DecimalNumber(0, edge_to_fix=RIGHT)
    d2 = DecimalNumber(0, edge_to_fix=RIGHT).shift(DOWN)

    d1.set_value(10)
    d2.set_value(1000)

 

 

 

Example

class DecimalTest(Scene):
    def construct(self):
        x_axis = NumberLine(x_min=-5, x_max=5)
        dot = Dot(color=RED, radius=0.15).move_to(x_axis.get_left())
        number = DecimalNumber(-5, color=RED).next_to(dot, UP)

        number.add_updater(lambda m: m.next_to(dot, UP))
        number.add_updater(lambda m: m.set_value(dot.get_center()[0]))

        self.add(x_axis,dot,number)
        self.play(dot.shift, RIGHT * 10, rate_func=there_and_back, run_time=10)
        self.wait()

 

 

 

반응형

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

[030]FunctionGraph  (0) 2020.05.11
[029]ParametricFunction  (0) 2020.05.11
[027]Ellipse/Annulus/AnnularSector/Sector  (0) 2020.05.11
[026]Circle  (0) 2020.05.11
[025]ArcBetweenPoints  (0) 2020.05.11