Merge branch 'master' of github.com:3b1b/manim into lighthouse2

This commit is contained in:
Grant Sanderson 2018-02-26 11:59:06 -08:00
commit 26388d35f4
8 changed files with 2379 additions and 50 deletions

View file

@ -3,6 +3,7 @@ import itertools as it
from helpers import * from helpers import *
import warnings
from mobject import Mobject, Group from mobject import Mobject, Group
from mobject.vectorized_mobject import VMobject from mobject.vectorized_mobject import VMobject
from mobject.tex_mobject import TextMobject from mobject.tex_mobject import TextMobject
@ -407,7 +408,7 @@ class Succession(Animation):
self.run_times = [anim.run_time for anim in animations] self.run_times = [anim.run_time for anim in animations]
if "run_time" in kwargs: if "run_time" in kwargs:
run_time = kwargs.pop("run_time") run_time = kwargs.pop("run_time")
else: warnings.warn("Succession doesn't currently support explicit run_time.")
run_time = sum(self.run_times) run_time = sum(self.run_times)
self.num_anims = len(animations) self.num_anims = len(animations)
if self.num_anims == 0: if self.num_anims == 0:
@ -465,11 +466,21 @@ class Succession(Animation):
self.current_alpha = alpha self.current_alpha = alpha
return return
i = 0 gt_alpha_list = filter(
while self.critical_alphas[i + 1] < alpha: lambda i : self.critical_alphas[i+1] >= alpha,
i = i + 1 range(len(self.critical_alphas)-1)
# TODO: Special handling if alpha < 0 or alpha > 1, to use )
# first or last sub-animation 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] # At this point, we should have self.critical_alphas[i] <= alpha <= self.critical_alphas[i +1]

View file

@ -394,7 +394,7 @@ class Camera(object):
y0 = max(y0, 0) y0 = max(y0, 0)
image[y0:y1, x0:x1] = stretched_impa[siy0:siy1, six0:six1] image[y0:y1, x0:x1] = stretched_impa[siy0:siy1, six0:six1]
else: 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), # List of all coordinates of pixels, given as (x, y),
# which matches the return type of points_to_pixel_coords, # which matches the return type of points_to_pixel_coords,
# even though np.array indexing naturally happens as (y, x) # even though np.array indexing naturally happens as (y, x)

View file

@ -29,6 +29,8 @@ class ImageMobject(Mobject):
else: else:
self.pixel_array = np.array(filename_or_array) self.pixel_array = np.array(filename_or_array)
self.change_to_rgba_array() self.change_to_rgba_array()
if self.invert:
self.pixel_array[:,:,:3] = 255-self.pixel_array[:,:,:3]
Mobject.__init__(self, **kwargs) Mobject.__init__(self, **kwargs)
def change_to_rgba_array(self): def change_to_rgba_array(self):

View file

@ -59,6 +59,13 @@ def get_fourier_graph(
for x, y in zip(frequencies, fft_output[:n_samples//2]) for x, y in zip(frequencies, fft_output[:n_samples//2])
]) ])
graph.highlight(color) 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 return graph
def get_fourier_transform( def get_fourier_transform(

File diff suppressed because it is too large Load diff

View 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

View file

@ -122,6 +122,7 @@ class ZoomedScene(Scene):
self.zoomed_camera.capture_mobjects( self.zoomed_camera.capture_mobjects(
mobjects, **kwargs mobjects, **kwargs
) )
def get_moving_mobjects(self, *animations): def get_moving_mobjects(self, *animations):
moving_mobjects = Scene.get_moving_mobjects(self, *animations) moving_mobjects = Scene.get_moving_mobjects(self, *animations)
if self.zoom_activated and self.little_rectangle in moving_mobjects: if self.zoom_activated and self.little_rectangle in moving_mobjects:

View file

@ -575,6 +575,7 @@ class PiCreatureScene(Scene):
time_to_blink = self.total_wait_time%self.seconds_to_blink == 0 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: if blink and self.any_pi_creatures_on_screen() and time_to_blink:
self.blink() self.blink()
self.num_plays -= 1 #This shouldn't count as an animation
else: else:
self.non_blink_wait() self.non_blink_wait()
time -= 1 time -= 1