mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Merge branch 'master' of github.com:3b1b/manim into lighthouse2
This commit is contained in:
commit
26388d35f4
8 changed files with 2379 additions and 50 deletions
|
@ -3,6 +3,7 @@ import itertools as it
|
|||
|
||||
from helpers import *
|
||||
|
||||
import warnings
|
||||
from mobject import Mobject, Group
|
||||
from mobject.vectorized_mobject import VMobject
|
||||
from mobject.tex_mobject import TextMobject
|
||||
|
@ -407,8 +408,8 @@ class Succession(Animation):
|
|||
self.run_times = [anim.run_time for anim in animations]
|
||||
if "run_time" in kwargs:
|
||||
run_time = kwargs.pop("run_time")
|
||||
else:
|
||||
run_time = sum(self.run_times)
|
||||
warnings.warn("Succession doesn't currently support explicit run_time.")
|
||||
run_time = sum(self.run_times)
|
||||
self.num_anims = len(animations)
|
||||
if self.num_anims == 0:
|
||||
self.empty = True
|
||||
|
@ -465,11 +466,21 @@ class Succession(Animation):
|
|||
self.current_alpha = alpha
|
||||
return
|
||||
|
||||
i = 0
|
||||
while self.critical_alphas[i + 1] < alpha:
|
||||
i = i + 1
|
||||
# TODO: Special handling if alpha < 0 or alpha > 1, to use
|
||||
# first or last sub-animation
|
||||
gt_alpha_list = filter(
|
||||
lambda i : self.critical_alphas[i+1] >= alpha,
|
||||
range(len(self.critical_alphas)-1)
|
||||
)
|
||||
if gt_alpha_list:
|
||||
i = gt_alpha_list[0]
|
||||
else:
|
||||
if not abs(alpha - 1) < 0.001:
|
||||
warnings.warn(
|
||||
"Rounding error not near alpha=1 in Succession.update_mobject," + \
|
||||
"instead alpha = %f"%alpha
|
||||
)
|
||||
print self.critical_alphas, alpha
|
||||
i = len(self.critical_alphas) - 2
|
||||
#
|
||||
|
||||
# At this point, we should have self.critical_alphas[i] <= alpha <= self.critical_alphas[i +1]
|
||||
|
||||
|
|
|
@ -394,7 +394,7 @@ class Camera(object):
|
|||
y0 = max(y0, 0)
|
||||
image[y0:y1, x0:x1] = stretched_impa[siy0:siy1, six0:six1]
|
||||
else:
|
||||
# Alternate (slower) tactice if image is tilted
|
||||
# Alternate (slower) tactic if image is tilted
|
||||
# List of all coordinates of pixels, given as (x, y),
|
||||
# which matches the return type of points_to_pixel_coords,
|
||||
# even though np.array indexing naturally happens as (y, x)
|
||||
|
@ -613,7 +613,7 @@ class MovingCamera(Camera):
|
|||
|
||||
def capture_mobjects(self, *args, **kwargs):
|
||||
self.space_center = self.mobject.get_center()
|
||||
self.realign_space_shape()
|
||||
self.realign_space_shape()
|
||||
Camera.capture_mobjects(self, *args, **kwargs)
|
||||
|
||||
def realign_space_shape(self):
|
||||
|
|
|
@ -29,6 +29,8 @@ class ImageMobject(Mobject):
|
|||
else:
|
||||
self.pixel_array = np.array(filename_or_array)
|
||||
self.change_to_rgba_array()
|
||||
if self.invert:
|
||||
self.pixel_array[:,:,:3] = 255-self.pixel_array[:,:,:3]
|
||||
Mobject.__init__(self, **kwargs)
|
||||
|
||||
def change_to_rgba_array(self):
|
||||
|
|
|
@ -59,6 +59,13 @@ def get_fourier_graph(
|
|||
for x, y in zip(frequencies, fft_output[:n_samples//2])
|
||||
])
|
||||
graph.highlight(color)
|
||||
f_min, f_max = [
|
||||
axes.x_axis.point_to_number(graph.points[i])
|
||||
for i in 0, -1
|
||||
]
|
||||
graph.underlying_function = lambda f : axes.y_axis.point_to_number(
|
||||
graph.point_from_proportion((f - f_min)/(f_max - f_min))
|
||||
)
|
||||
return graph
|
||||
|
||||
def get_fourier_transform(
|
File diff suppressed because it is too large
Load diff
23
scene/moving_camera_scene.py
Normal file
23
scene/moving_camera_scene.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
from helpers import *
|
||||
|
||||
from camera import MovingCamera
|
||||
from scene import Scene
|
||||
from topics.geometry import ScreenRectangle
|
||||
|
||||
class MovingCameraScene(Scene):
|
||||
def setup(self):
|
||||
self.camera_frame = ScreenRectangle(height = 2*SPACE_HEIGHT)
|
||||
self.camera_frame.set_stroke(width = 0)
|
||||
self.camera = MovingCamera(
|
||||
self.camera_frame, **self.camera_config
|
||||
)
|
||||
return self
|
||||
|
||||
def get_moving_mobjects(self, *animations):
|
||||
# TODO: Code repetition from ZoomedScene
|
||||
moving_mobjects = Scene.get_moving_mobjects(self, *animations)
|
||||
if self.camera_frame in moving_mobjects:
|
||||
# When the camera is moving, so is everything,
|
||||
return self.mobjects
|
||||
else:
|
||||
return moving_mobjects
|
|
@ -122,6 +122,7 @@ class ZoomedScene(Scene):
|
|||
self.zoomed_camera.capture_mobjects(
|
||||
mobjects, **kwargs
|
||||
)
|
||||
|
||||
def get_moving_mobjects(self, *animations):
|
||||
moving_mobjects = Scene.get_moving_mobjects(self, *animations)
|
||||
if self.zoom_activated and self.little_rectangle in moving_mobjects:
|
||||
|
|
|
@ -575,6 +575,7 @@ class PiCreatureScene(Scene):
|
|||
time_to_blink = self.total_wait_time%self.seconds_to_blink == 0
|
||||
if blink and self.any_pi_creatures_on_screen() and time_to_blink:
|
||||
self.blink()
|
||||
self.num_plays -= 1 #This shouldn't count as an animation
|
||||
else:
|
||||
self.non_blink_wait()
|
||||
time -= 1
|
||||
|
|
Loading…
Add table
Reference in a new issue