mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Merge branch 'master' of https://github.com/3b1b/manim into WindingNumber
This commit is contained in:
commit
36aade767c
5 changed files with 1192 additions and 11 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -13,3 +13,5 @@ ben_cairo_test.py
|
||||||
*.xml
|
*.xml
|
||||||
*.iml
|
*.iml
|
||||||
|
|
||||||
|
|
||||||
|
primes.py
|
||||||
|
|
|
@ -383,7 +383,7 @@ class Introduce1DFunctionCase(Scene):
|
||||||
):
|
):
|
||||||
|
|
||||||
axes = self.axes
|
axes = self.axes
|
||||||
rect = Rectangle()
|
rect = self.rect = Rectangle()
|
||||||
rect.set_stroke(width = 0)
|
rect.set_stroke(width = 0)
|
||||||
rect.set_fill(YELLOW, 0.5)
|
rect.set_fill(YELLOW, 0.5)
|
||||||
rect.replace(Line(
|
rect.replace(Line(
|
||||||
|
@ -430,7 +430,10 @@ class Introduce1DFunctionCase(Scene):
|
||||||
midpoint_line.set_stroke(width = 0)
|
midpoint_line.set_stroke(width = 0)
|
||||||
|
|
||||||
#Restrict to by a half each time
|
#Restrict to by a half each time
|
||||||
kwargs = {"mention_signs" : False}
|
kwargs = {
|
||||||
|
"mention_signs" : False,
|
||||||
|
"show_decimal" : zoom,
|
||||||
|
}
|
||||||
for x in range(n_iterations - 1):
|
for x in range(n_iterations - 1):
|
||||||
x_mid = np.mean(end_points)
|
x_mid = np.mean(end_points)
|
||||||
leftovers_mid = self.compare_graphs_at_x(f_graph, g_graph, x_mid, **kwargs)
|
leftovers_mid = self.compare_graphs_at_x(f_graph, g_graph, x_mid, **kwargs)
|
||||||
|
@ -463,8 +466,14 @@ class Introduce1DFunctionCase(Scene):
|
||||||
*added_anims
|
*added_anims
|
||||||
)
|
)
|
||||||
if zoom:
|
if zoom:
|
||||||
everything = VGroup(*self.mobjects)
|
|
||||||
factor = 2.0/rect.get_width()
|
factor = 2.0/rect.get_width()
|
||||||
|
everything = VGroup(*self.mobjects)
|
||||||
|
decimal_index = everything.submobjects.index(decimal)
|
||||||
|
midpoint_line_index = everything.submobjects.index(midpoint_line)
|
||||||
|
everything.generate_target()
|
||||||
|
everything.target.scale(factor, about_point = rect.get_center())
|
||||||
|
everything.target[decimal_index].scale(1./factor, about_edge = UP)
|
||||||
|
everything.target[midpoint_line_index].scale(1./factor)
|
||||||
if factor > 1:
|
if factor > 1:
|
||||||
self.play(
|
self.play(
|
||||||
everything.scale, factor,
|
everything.scale, factor,
|
||||||
|
@ -500,6 +509,33 @@ class Introduce1DFunctionCase(Scene):
|
||||||
leftovers.add(v_line)
|
leftovers.add(v_line)
|
||||||
|
|
||||||
added_anims = []
|
added_anims = []
|
||||||
|
if show_decimal:
|
||||||
|
decimal = DecimalNumber(
|
||||||
|
axes.x_axis.point_to_number(arrow.get_start()),
|
||||||
|
num_decimal_points = 3,
|
||||||
|
# show_ellipsis = True,
|
||||||
|
)
|
||||||
|
height = self.rect.get_height()
|
||||||
|
decimal.scale_to_fit_height(height)
|
||||||
|
next_to_kwargs = {
|
||||||
|
"buff" : height,
|
||||||
|
}
|
||||||
|
if too_high:
|
||||||
|
decimal.next_to(arrow, DOWN, **next_to_kwargs)
|
||||||
|
if hasattr(self, "last_up_arrow_decimal"):
|
||||||
|
added_anims += [FadeOut(self.last_up_arrow_decimal)]
|
||||||
|
self.last_up_arrow_decimal = decimal
|
||||||
|
else:
|
||||||
|
decimal.next_to(arrow, UP, **next_to_kwargs)
|
||||||
|
if hasattr(self, "last_down_arrow_decimal"):
|
||||||
|
added_anims += [FadeOut(self.last_down_arrow_decimal)]
|
||||||
|
self.last_down_arrow_decimal = decimal
|
||||||
|
line = Line(decimal, arrow, buff = 0)
|
||||||
|
# line.match_color(arrow)
|
||||||
|
line.set_stroke(WHITE, 1)
|
||||||
|
decimal.add(line)
|
||||||
|
added_anims += [FadeIn(decimal)]
|
||||||
|
|
||||||
if mention_signs:
|
if mention_signs:
|
||||||
if too_high:
|
if too_high:
|
||||||
sign_word = TextMobject("Positive")
|
sign_word = TextMobject("Positive")
|
||||||
|
@ -1157,12 +1193,12 @@ class EveryOutputPointHasAColor(ColorMappedObjectsScene):
|
||||||
title.scale(1.5)
|
title.scale(1.5)
|
||||||
title.to_edge(UP, buff = MED_SMALL_BUFF)
|
title.to_edge(UP, buff = MED_SMALL_BUFF)
|
||||||
title.set_stroke(BLACK, 1)
|
title.set_stroke(BLACK, 1)
|
||||||
self.add_foreground_mobjects(title)
|
# self.add_foreground_mobjects(title)
|
||||||
|
|
||||||
plane = NumberPlane()
|
plane = NumberPlane()
|
||||||
plane.fade(0.5)
|
plane.fade(0.5)
|
||||||
plane.axes.set_stroke(WHITE, 3)
|
plane.axes.set_stroke(WHITE, 3)
|
||||||
plane.add(BackgroundRectangle(title))
|
# plane.add(BackgroundRectangle(title))
|
||||||
self.add(plane)
|
self.add(plane)
|
||||||
|
|
||||||
|
|
||||||
|
|
1129
old_projects/pi_day.py
Normal file
1129
old_projects/pi_day.py
Normal file
File diff suppressed because it is too large
Load diff
|
@ -29,6 +29,7 @@ MOUTH_INDEX = 5
|
||||||
class PiCreature(SVGMobject):
|
class PiCreature(SVGMobject):
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
"color" : BLUE_E,
|
"color" : BLUE_E,
|
||||||
|
"file_name_prefix" : "PiCreatures",
|
||||||
"stroke_width" : 0,
|
"stroke_width" : 0,
|
||||||
"stroke_color" : BLACK,
|
"stroke_color" : BLACK,
|
||||||
"fill_opacity" : 1.0,
|
"fill_opacity" : 1.0,
|
||||||
|
@ -43,18 +44,19 @@ class PiCreature(SVGMobject):
|
||||||
"left_arm_range" : [.34, .462],
|
"left_arm_range" : [.34, .462],
|
||||||
}
|
}
|
||||||
def __init__(self, mode = "plain", **kwargs):
|
def __init__(self, mode = "plain", **kwargs):
|
||||||
|
digest_config(self, kwargs)
|
||||||
self.parts_named = False
|
self.parts_named = False
|
||||||
try:
|
try:
|
||||||
svg_file = os.path.join(
|
svg_file = os.path.join(
|
||||||
PI_CREATURE_DIR,
|
PI_CREATURE_DIR,
|
||||||
"PiCreatures_%s.svg"%mode
|
"%s_%s.svg"%(self.file_name_prefix, mode)
|
||||||
)
|
)
|
||||||
SVGMobject.__init__(self, file_name = svg_file, **kwargs)
|
SVGMobject.__init__(self, file_name = svg_file, **kwargs)
|
||||||
except:
|
except:
|
||||||
warnings.warn("No PiCreature design with mode %s"%mode)
|
warnings.warn("No %s design with mode %s"%(self.file_name_prefix, mode))
|
||||||
svg_file = os.path.join(
|
svg_file = os.path.join(
|
||||||
FILE_DIR,
|
FILE_DIR,
|
||||||
"PiCreatures_plain.svg"
|
"PiCreatures_plain.svg",
|
||||||
)
|
)
|
||||||
SVGMobject.__init__(self, file_name = svg_file, **kwargs)
|
SVGMobject.__init__(self, file_name = svg_file, **kwargs)
|
||||||
|
|
||||||
|
@ -210,7 +212,7 @@ class PiCreature(SVGMobject):
|
||||||
|
|
||||||
def get_all_pi_creature_modes():
|
def get_all_pi_creature_modes():
|
||||||
result = []
|
result = []
|
||||||
prefix = "PiCreatures_"
|
prefix = "%s_"%PiCreature.CONFIG["file_name_prefix"]
|
||||||
suffix = ".svg"
|
suffix = ".svg"
|
||||||
for file in os.listdir(PI_CREATURE_DIR):
|
for file in os.listdir(PI_CREATURE_DIR):
|
||||||
if file.startswith(prefix) and file.endswith(suffix):
|
if file.startswith(prefix) and file.endswith(suffix):
|
||||||
|
@ -253,6 +255,17 @@ class BabyPiCreature(PiCreature):
|
||||||
pupil.scale_in_place(self.pupil_scale_factor)
|
pupil.scale_in_place(self.pupil_scale_factor)
|
||||||
self.look(looking_direction)
|
self.look(looking_direction)
|
||||||
|
|
||||||
|
class TauCreature(PiCreature):
|
||||||
|
CONFIG = {
|
||||||
|
"file_name_prefix" : "TauCreatures"
|
||||||
|
}
|
||||||
|
|
||||||
|
class ThreeLeggedPiCreature(PiCreature):
|
||||||
|
CONFIG = {
|
||||||
|
"file_name_prefix" : "ThreeLeggedPiCreatures"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Blink(ApplyMethod):
|
class Blink(ApplyMethod):
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
"rate_func" : squish_rate_func(there_and_back)
|
"rate_func" : squish_rate_func(there_and_back)
|
||||||
|
|
|
@ -3,7 +3,8 @@ from helpers import *
|
||||||
|
|
||||||
from scene.scene import Scene
|
from scene.scene import Scene
|
||||||
from animation import Animation
|
from animation import Animation
|
||||||
from animation.simple_animations import Write, DrawBorderThenFill, LaggedStart
|
from animation.simple_animations import Write, DrawBorderThenFill
|
||||||
|
from animation.compositions import LaggedStart
|
||||||
from animation.transform import FadeIn, FadeOut, ApplyMethod
|
from animation.transform import FadeIn, FadeOut, ApplyMethod
|
||||||
from mobject.vectorized_mobject import VGroup
|
from mobject.vectorized_mobject import VGroup
|
||||||
from mobject.tex_mobject import TexMobject, TextMobject
|
from mobject.tex_mobject import TexMobject, TextMobject
|
||||||
|
@ -132,7 +133,7 @@ class PatreonEndScreen(PatreonThanks):
|
||||||
self.scroll_through_patrons()
|
self.scroll_through_patrons()
|
||||||
|
|
||||||
def add_title(self):
|
def add_title(self):
|
||||||
title = TextMobject("Clicky Stuffs")
|
title = self.title = TextMobject("Clicky Stuffs")
|
||||||
title.scale(1.5)
|
title.scale(1.5)
|
||||||
title.to_edge(UP, buff = MED_SMALL_BUFF)
|
title.to_edge(UP, buff = MED_SMALL_BUFF)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue