mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
commit
3152def8ac
6 changed files with 1212 additions and 28 deletions
File diff suppressed because it is too large
Load diff
|
@ -113,6 +113,17 @@ class Write(DrawBorderThenFill):
|
||||||
else:
|
else:
|
||||||
self.run_time = 2
|
self.run_time = 2
|
||||||
|
|
||||||
|
|
||||||
|
class ShowIncreasingSubsets(Animation):
|
||||||
|
def __init__(self, group, **kwargs):
|
||||||
|
self.all_submobs = group.submobjects
|
||||||
|
Animation.__init__(self, group, **kwargs)
|
||||||
|
|
||||||
|
def update_mobject(self, alpha):
|
||||||
|
n_submobs = len(self.all_submobs)
|
||||||
|
index = int(alpha * n_submobs)
|
||||||
|
self.mobject.submobjects = self.all_submobs[:index]
|
||||||
|
|
||||||
# Fading
|
# Fading
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -392,7 +392,10 @@ class Camera(object):
|
||||||
vmobject
|
vmobject
|
||||||
)
|
)
|
||||||
ctx.set_line_width(
|
ctx.set_line_width(
|
||||||
width * self.cairo_line_width_multiple
|
width * self.cairo_line_width_multiple *
|
||||||
|
# This ensures lines have constant width
|
||||||
|
# as you zoom in on them.
|
||||||
|
(self.get_frame_width() / FRAME_WIDTH)
|
||||||
)
|
)
|
||||||
ctx.stroke_preserve()
|
ctx.stroke_preserve()
|
||||||
return self
|
return self
|
||||||
|
|
|
@ -298,7 +298,7 @@ class TeacherStudentsScene(PiCreatureScene):
|
||||||
"raise_left_hand",
|
"raise_left_hand",
|
||||||
])
|
])
|
||||||
kwargs["target_mode"] = target_mode
|
kwargs["target_mode"] = target_mode
|
||||||
student = self.get_students()[kwargs.get("student_index", 1)]
|
student = self.get_students()[kwargs.get("student_index", 2)]
|
||||||
return self.pi_creature_says(
|
return self.pi_creature_says(
|
||||||
student, *content, **kwargs
|
student, *content, **kwargs
|
||||||
)
|
)
|
||||||
|
@ -309,7 +309,7 @@ class TeacherStudentsScene(PiCreatureScene):
|
||||||
)
|
)
|
||||||
|
|
||||||
def student_thinks(self, *content, **kwargs):
|
def student_thinks(self, *content, **kwargs):
|
||||||
student = self.get_students()[kwargs.get("student_index", 1)]
|
student = self.get_students()[kwargs.get("student_index", 2)]
|
||||||
return self.pi_creature_thinks(student, *content, **kwargs)
|
return self.pi_creature_thinks(student, *content, **kwargs)
|
||||||
|
|
||||||
def change_all_student_modes(self, mode, **kwargs):
|
def change_all_student_modes(self, mode, **kwargs):
|
||||||
|
|
|
@ -23,6 +23,7 @@ class Arc(VMobject):
|
||||||
"start_angle": 0,
|
"start_angle": 0,
|
||||||
"num_anchors": 9,
|
"num_anchors": 9,
|
||||||
"anchors_span_full_range": True,
|
"anchors_span_full_range": True,
|
||||||
|
"arc_center": ORIGIN,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, angle, **kwargs):
|
def __init__(self, angle, **kwargs):
|
||||||
|
@ -50,6 +51,7 @@ class Arc(VMobject):
|
||||||
anchors, handles1, handles2
|
anchors, handles1, handles2
|
||||||
)
|
)
|
||||||
self.scale(self.radius, about_point=ORIGIN)
|
self.scale(self.radius, about_point=ORIGIN)
|
||||||
|
self.shift(self.arc_center)
|
||||||
|
|
||||||
def add_tip(self, tip_length=0.25, at_start=False, at_end=True):
|
def add_tip(self, tip_length=0.25, at_start=False, at_end=True):
|
||||||
# clear out any old tips
|
# clear out any old tips
|
||||||
|
@ -180,6 +182,14 @@ class Circle(Arc):
|
||||||
np.sqrt(mobject.get_width()**2 + mobject.get_height()**2))
|
np.sqrt(mobject.get_width()**2 + mobject.get_height()**2))
|
||||||
self.scale(buffer_factor)
|
self.scale(buffer_factor)
|
||||||
|
|
||||||
|
def get_point_from_angle(self, angle):
|
||||||
|
start_angle = angle_of_vector(
|
||||||
|
self.points[0] - self.get_center()
|
||||||
|
)
|
||||||
|
return self.point_from_proportion(
|
||||||
|
(angle - start_angle) / TAU
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Dot(Circle):
|
class Dot(Circle):
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
|
|
|
@ -105,7 +105,10 @@ class DecimalNumber(VMobject):
|
||||||
full_config.update(self.initial_config)
|
full_config.update(self.initial_config)
|
||||||
full_config.update(config)
|
full_config.update(config)
|
||||||
new_decimal = DecimalNumber(number, **full_config)
|
new_decimal = DecimalNumber(number, **full_config)
|
||||||
new_decimal.match_height(self)
|
# new_decimal.match_height(self)
|
||||||
|
new_decimal.scale(
|
||||||
|
self[0].get_height() / new_decimal[0].get_height()
|
||||||
|
)
|
||||||
new_decimal.move_to(self, self.edge_to_fix)
|
new_decimal.move_to(self, self.edge_to_fix)
|
||||||
new_decimal.match_style(self)
|
new_decimal.match_style(self)
|
||||||
|
|
||||||
|
@ -129,3 +132,6 @@ class Integer(DecimalNumber):
|
||||||
|
|
||||||
def increment_value(self):
|
def increment_value(self):
|
||||||
self.set_value(self.get_value() + 1)
|
self.set_value(self.get_value() + 1)
|
||||||
|
|
||||||
|
def get_value(self):
|
||||||
|
return int(np.round(super().get_value()))
|
||||||
|
|
Loading…
Add table
Reference in a new issue