Partial completion of TwoDBoxWithSliders in highD.py

This commit is contained in:
Grant Sanderson 2017-08-08 21:42:23 -07:00
parent dca46ba2e8
commit a765a64bc7
4 changed files with 912 additions and 27 deletions

928
highD.py

File diff suppressed because it is too large Load diff

View file

@ -80,6 +80,8 @@ class TexMobject(SVGMobject):
if tex in ["\\over", "\\overline"]: if tex in ["\\over", "\\overline"]:
#fraction line needs something to be over #fraction line needs something to be over
tex += "\\," tex += "\\,"
if tex == "\\sqrt":
tex += "{\\quad}"
for t1, t2 in ("\\left", "\\right"), ("\\right", "\\left"): for t1, t2 in ("\\left", "\\right"), ("\\right", "\\left"):
should_replace = reduce(op.and_, [ should_replace = reduce(op.and_, [
t1 in tex, t1 in tex,

View file

@ -32,7 +32,7 @@ class NumberLine(VMobject):
def generate_points(self): def generate_points(self):
self.main_line = Line(self.x_min*RIGHT, self.x_max*RIGHT) self.main_line = Line(self.x_min*RIGHT, self.x_max*RIGHT)
self.tick_marks = VMobject() self.tick_marks = VGroup()
self.add(self.main_line, self.tick_marks) self.add(self.main_line, self.tick_marks)
for x in self.get_tick_numbers(): for x in self.get_tick_numbers():
self.add_tick(x, self.tick_size) self.add_tick(x, self.tick_size)

View file

@ -12,7 +12,7 @@ class DecimalNumber(VMobject):
} }
def __init__(self, float_num, **kwargs): def __init__(self, float_num, **kwargs):
digest_config(self, kwargs) digest_config(self, kwargs)
num_string = '%.*f' % (self.num_decimal_points, float_num) num_string = '%.*f'%(self.num_decimal_points, float_num)
VMobject.__init__(self, *[ VMobject.__init__(self, *[
TexMobject(char) TexMobject(char)
for char in num_string for char in num_string
@ -64,7 +64,10 @@ class ChangingDecimal(Animation):
def update_number(self, alpha): def update_number(self, alpha):
decimal = self.decimal_number decimal = self.decimal_number
new_decimal = DecimalNumber(self.number_update_func(alpha)) new_decimal = DecimalNumber(
self.number_update_func(alpha),
num_decimal_points = self.num_decimal_points
)
new_decimal.replace(decimal, dim_to_match = 1) new_decimal.replace(decimal, dim_to_match = 1)
new_decimal.highlight(decimal.get_color()) new_decimal.highlight(decimal.get_color())
decimal.align_data(new_decimal) decimal.align_data(new_decimal)