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
|
||||
*.iml
|
||||
|
||||
|
||||
primes.py
|
||||
|
|
|
@ -383,7 +383,7 @@ class Introduce1DFunctionCase(Scene):
|
|||
):
|
||||
|
||||
axes = self.axes
|
||||
rect = Rectangle()
|
||||
rect = self.rect = Rectangle()
|
||||
rect.set_stroke(width = 0)
|
||||
rect.set_fill(YELLOW, 0.5)
|
||||
rect.replace(Line(
|
||||
|
@ -430,7 +430,10 @@ class Introduce1DFunctionCase(Scene):
|
|||
midpoint_line.set_stroke(width = 0)
|
||||
|
||||
#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):
|
||||
x_mid = np.mean(end_points)
|
||||
leftovers_mid = self.compare_graphs_at_x(f_graph, g_graph, x_mid, **kwargs)
|
||||
|
@ -463,8 +466,14 @@ class Introduce1DFunctionCase(Scene):
|
|||
*added_anims
|
||||
)
|
||||
if zoom:
|
||||
everything = VGroup(*self.mobjects)
|
||||
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:
|
||||
self.play(
|
||||
everything.scale, factor,
|
||||
|
@ -500,6 +509,33 @@ class Introduce1DFunctionCase(Scene):
|
|||
leftovers.add(v_line)
|
||||
|
||||
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 too_high:
|
||||
sign_word = TextMobject("Positive")
|
||||
|
@ -1157,12 +1193,12 @@ class EveryOutputPointHasAColor(ColorMappedObjectsScene):
|
|||
title.scale(1.5)
|
||||
title.to_edge(UP, buff = MED_SMALL_BUFF)
|
||||
title.set_stroke(BLACK, 1)
|
||||
self.add_foreground_mobjects(title)
|
||||
# self.add_foreground_mobjects(title)
|
||||
|
||||
plane = NumberPlane()
|
||||
plane.fade(0.5)
|
||||
plane.axes.set_stroke(WHITE, 3)
|
||||
plane.add(BackgroundRectangle(title))
|
||||
# plane.add(BackgroundRectangle(title))
|
||||
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):
|
||||
CONFIG = {
|
||||
"color" : BLUE_E,
|
||||
"file_name_prefix" : "PiCreatures",
|
||||
"stroke_width" : 0,
|
||||
"stroke_color" : BLACK,
|
||||
"fill_opacity" : 1.0,
|
||||
|
@ -43,18 +44,19 @@ class PiCreature(SVGMobject):
|
|||
"left_arm_range" : [.34, .462],
|
||||
}
|
||||
def __init__(self, mode = "plain", **kwargs):
|
||||
digest_config(self, kwargs)
|
||||
self.parts_named = False
|
||||
try:
|
||||
svg_file = os.path.join(
|
||||
PI_CREATURE_DIR,
|
||||
"PiCreatures_%s.svg"%mode
|
||||
"%s_%s.svg"%(self.file_name_prefix, mode)
|
||||
)
|
||||
SVGMobject.__init__(self, file_name = svg_file, **kwargs)
|
||||
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(
|
||||
FILE_DIR,
|
||||
"PiCreatures_plain.svg"
|
||||
"PiCreatures_plain.svg",
|
||||
)
|
||||
SVGMobject.__init__(self, file_name = svg_file, **kwargs)
|
||||
|
||||
|
@ -210,7 +212,7 @@ class PiCreature(SVGMobject):
|
|||
|
||||
def get_all_pi_creature_modes():
|
||||
result = []
|
||||
prefix = "PiCreatures_"
|
||||
prefix = "%s_"%PiCreature.CONFIG["file_name_prefix"]
|
||||
suffix = ".svg"
|
||||
for file in os.listdir(PI_CREATURE_DIR):
|
||||
if file.startswith(prefix) and file.endswith(suffix):
|
||||
|
@ -253,6 +255,17 @@ class BabyPiCreature(PiCreature):
|
|||
pupil.scale_in_place(self.pupil_scale_factor)
|
||||
self.look(looking_direction)
|
||||
|
||||
class TauCreature(PiCreature):
|
||||
CONFIG = {
|
||||
"file_name_prefix" : "TauCreatures"
|
||||
}
|
||||
|
||||
class ThreeLeggedPiCreature(PiCreature):
|
||||
CONFIG = {
|
||||
"file_name_prefix" : "ThreeLeggedPiCreatures"
|
||||
}
|
||||
|
||||
|
||||
class Blink(ApplyMethod):
|
||||
CONFIG = {
|
||||
"rate_func" : squish_rate_func(there_and_back)
|
||||
|
|
|
@ -3,7 +3,8 @@ from helpers import *
|
|||
|
||||
from scene.scene import Scene
|
||||
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 mobject.vectorized_mobject import VGroup
|
||||
from mobject.tex_mobject import TexMobject, TextMobject
|
||||
|
@ -132,7 +133,7 @@ class PatreonEndScreen(PatreonThanks):
|
|||
self.scroll_through_patrons()
|
||||
|
||||
def add_title(self):
|
||||
title = TextMobject("Clicky Stuffs")
|
||||
title = self.title = TextMobject("Clicky Stuffs")
|
||||
title.scale(1.5)
|
||||
title.to_edge(UP, buff = MED_SMALL_BUFF)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue