Skip to content

Commit e1e66f3

Browse files
authored
Merge pull request 3b1b#752 from 3b1b/hyperdarts
Hyperdarts
2 parents e85beb9 + c4aefe9 commit e1e66f3

File tree

10 files changed

+5929
-13
lines changed

10 files changed

+5929
-13
lines changed

active_projects/hyperdarts.py

Lines changed: 920 additions & 0 deletions
Large diffs are not rendered by default.

active_projects/spirals.py

Lines changed: 4926 additions & 0 deletions
Large diffs are not rendered by default.

manimlib/animation/composition.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def __init__(self, *animations, **kwargs):
3333
self.group = Group(*remove_list_redundancies(
3434
[anim.mobject for anim in animations]
3535
))
36+
self.init_run_time()
3637
Animation.__init__(self, self.group, **kwargs)
3738

3839
def get_all_mobjects(self):
@@ -41,7 +42,7 @@ def get_all_mobjects(self):
4142
def begin(self):
4243
for anim in self.animations:
4344
anim.begin()
44-
self.init_run_time()
45+
# self.init_run_time()
4546

4647
def finish(self):
4748
for anim in self.animations:

manimlib/animation/creation.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
from manimlib.animation.animation import Animation
2+
from manimlib.animation.composition import Succession
23
from manimlib.mobject.types.vectorized_mobject import VMobject
4+
from manimlib.mobject.mobject import Group
35
from manimlib.utils.bezier import integer_interpolate
46
from manimlib.utils.config_ops import digest_config
57
from manimlib.utils.rate_functions import linear
68
from manimlib.utils.rate_functions import double_smooth
79
from manimlib.utils.rate_functions import smooth
810

911
import numpy as np
12+
import itertools as it
1013

1114

1215
class ShowPartial(Animation):
@@ -132,4 +135,42 @@ def __init__(self, group, **kwargs):
132135
def interpolate_mobject(self, alpha):
133136
n_submobs = len(self.all_submobs)
134137
index = int(self.int_func(alpha * n_submobs))
138+
self.update_submobject_list(index)
139+
140+
def update_submobject_list(self, index):
135141
self.mobject.submobjects = self.all_submobs[:index]
142+
143+
144+
class ShowSubmobjectsOneByOne(ShowIncreasingSubsets):
145+
def __init__(self, group, **kwargs):
146+
new_group = Group(*group)
147+
super().__init__(new_group, **kwargs)
148+
149+
def update_submobject_list(self, index):
150+
# N = len(self.all_submobs)
151+
if index == 0:
152+
self.mobject.submobjects = []
153+
else:
154+
self.mobject.submobjects = self.all_submobs[index - 1]
155+
156+
157+
# TODO, this is broken...
158+
class AddTextWordByWord(Succession):
159+
CONFIG = {
160+
# If given a value for run_time, it will
161+
# override the time_per_char
162+
"run_time": None,
163+
"time_per_char": 0.06,
164+
}
165+
166+
def __init__(self, text_mobject, **kwargs):
167+
digest_config(self, kwargs)
168+
tpc = self.time_per_char
169+
anims = it.chain(*[
170+
[
171+
ShowIncreasingSubsets(word, run_time=tpc * len(word)),
172+
Animation(word, run_time=0.005 * len(word)**1.5),
173+
]
174+
for word in text_mobject
175+
])
176+
super().__init__(*anims, **kwargs)

manimlib/for_3b1b_videos/common_scenes.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ class PatreonEndScreen(PatreonThanks, PiCreatureScene):
154154
"randomize_order": True,
155155
"capitalize": True,
156156
"name_y_spacing": 0.7,
157-
# "thanks_words": "Funded by the community, with special thanks to:",
158-
"thanks_words": "Early access, name in credits and more at 3b1b.org/support",
157+
"thanks_words": "My thanks to all the patrons among you",
159158
}
160159

161160
def construct(self):
@@ -245,7 +244,7 @@ def scroll_through_patrons(self):
245244
columns.next_to(underline, DOWN, buff=2)
246245

247246
columns.generate_target()
248-
columns.target.to_edge(DOWN, buff=2)
247+
columns.target.to_edge(DOWN, buff=4)
249248
vect = columns.target.get_center() - columns.get_center()
250249
distance = get_norm(vect)
251250
wait_time = 20
@@ -259,11 +258,15 @@ def scroll_through_patrons(self):
259258
self.wait(wait_time)
260259

261260
def modify_patron_name(self, name):
262-
if name.lower() == "RedAgent14".lower():
263-
return "Brian Shepetofsky"
264-
elif name.lower() == "DeathByShrimp".lower():
265-
return "Henry Bresnahan"
266-
261+
modification_map = {
262+
"RedAgent14": "Brian Shepetofsky",
263+
"DeathByShrimp": "Henry Bresnahan",
264+
"akostrikov": "Aleksandr Kostrikov",
265+
"Jacob Baxter": "Will Fleshman",
266+
}
267+
for n1, n2 in modification_map.items():
268+
if name.lower() == n1.lower():
269+
return n2
267270
return name
268271

269272

manimlib/mobject/geometry.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,6 @@ def get_length(self):
202202
return get_norm(start - end)
203203

204204

205-
206-
207205
class Arc(TipableVMobject):
208206
CONFIG = {
209207
"radius": 1.0,

manimlib/mobject/types/point_cloud_mobject.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ def set_color(self, color=YELLOW_C, family=True):
5050
self.color = color
5151
return self
5252

53+
def get_stroke_width(self):
54+
return self.stroke_width
55+
56+
def set_stroke_width(self, width, family=True):
57+
mobs = self.family_members_with_points() if family else [self]
58+
for mob in mobs:
59+
mob.stroke_width = width
60+
return self
61+
5362
# def set_color_by_gradient(self, start_color, end_color):
5463
def set_color_by_gradient(self, *colors):
5564
self.rgbas = np.array(list(map(
@@ -158,6 +167,12 @@ def interpolate_color(self, mobject1, mobject2, alpha):
158167
self.rgbas = interpolate(
159168
mobject1.rgbas, mobject2.rgbas, alpha
160169
)
170+
self.set_stroke_width(interpolate(
171+
mobject1.get_stroke_width(),
172+
mobject2.get_stroke_width(),
173+
alpha,
174+
))
175+
return self
161176

162177
def pointwise_become_partial(self, mobject, a, b):
163178
lower_index, upper_index = [
@@ -206,6 +221,14 @@ def __init__(self, **kwargs):
206221
Mobject.__init__(self, **kwargs)
207222

208223

224+
class PGroup(PMobject):
225+
def __init__(self, *pmobs, **kwargs):
226+
if not all([isinstance(m, PMobject) for m in pmobs]):
227+
raise Exception("All submobjects must be of type PMobject")
228+
super().__init__(**kwargs)
229+
self.add(*pmobs)
230+
231+
209232
class PointCloudDot(Mobject1D):
210233
CONFIG = {
211234
"radius": 0.075,

manimlib/scene/scene.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,8 @@ def add_frames(self, *frames):
543543
self.file_writer.write_frame(frame)
544544

545545
def add_sound(self, sound_file, time_offset=0, gain=None, **kwargs):
546+
if self.skip_animations:
547+
return
546548
time = self.get_time() + time_offset
547549
self.file_writer.add_sound(sound_file, time, gain, **kwargs)
548550

old_projects/name_animation.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ def __str__(self):
8888
return self.animated_name.replace(" ", "") + "Animation"
8989

9090

91-
names = []
91+
names = [
92+
"Happy 18th Birthday\\\\Pranavi Hiremath!"
93+
]
9294

9395
if __name__ == "__main__":
9496
for name in names:

stage_scenes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def stage_scenes(module_name):
4545
animation_dir = os.path.join(
4646
os.path.expanduser('~'),
4747
"Dropbox (3Blue1Brown)/3Blue1Brown Team Folder/videos",
48-
"windmill", "1440p60"
48+
"spirals", "1440p60"
4949
)
5050
#
5151
files = os.listdir(animation_dir)

0 commit comments

Comments
 (0)