Refactor generate_logo

This commit is contained in:
Grant Sanderson
2015-10-29 17:00:46 -07:00
parent e4b61dc5df
commit f581446c4e
9 changed files with 42 additions and 23 deletions

View File

@ -23,10 +23,14 @@ class LogoGeneration(Scene):
"sphere_blue" : DARK_BLUE, "sphere_blue" : DARK_BLUE,
"sphere_brown" : LIGHT_BROWN, "sphere_brown" : LIGHT_BROWN,
"interpolation_factor" : 0.3, "interpolation_factor" : 0.3,
"frame_duration" : 0.01, "frame_duration" : 0.03,
"run_time" : 3,
} }
def construct(self): def construct(self):
digest_config(self, {})
## Usually shouldn't need this...
self.frame_duration = self.DEFAULT_CONFIG["frame_duration"]
##
digest_config(self, {}) digest_config(self, {})
circle = Circle( circle = Circle(
density = self.circle_density, density = self.circle_density,
@ -59,11 +63,11 @@ class LogoGeneration(Scene):
self.play(Transform( self.play(Transform(
circle, iris, circle, iris,
run_time = DEFAULT_ANIMATION_RUN_TIME run_time = self.run_time
)) ))
self.frames = drag_pixels(self.frames) self.frames = drag_pixels(self.frames)
self.set_frame_as_background() self.save_image(IMAGE_DIR)
self.save_image() self.show_frame()
self.add(name) self.add(name)
self.dither() self.dither()
print "Dragging pixels..." print "Dragging pixels..."

View File

@ -118,7 +118,7 @@ def random_color():
################################################ ################################################
def straight_path(start_points, end_points, alpha): def straight_path(start_points, end_points, alpha):
return (1-alpha)*start_points + alpha*end_points return interpolate(start_points, end_points, alpha)
def path_along_arc(arc_angle): def path_along_arc(arc_angle):
""" """

View File

@ -7,9 +7,9 @@ from helpers import *
class TexMobject(Mobject): class TexMobject(Mobject):
DEFAULT_CONFIG = { DEFAULT_CONFIG = {
"template_tex_file" : TEMPLATE_TEX_FILE, "template_tex_file" : TEMPLATE_TEX_FILE,
"color" : WHITE, "color" : WHITE,
"point_thickness" : 1, "point_thickness" : 1,
"should_center" : False, "should_center" : False,
} }
def __init__(self, expression, **kwargs): def __init__(self, expression, **kwargs):
if "size" not in kwargs: if "size" not in kwargs:

View File

@ -241,6 +241,7 @@ class Scene(object):
@staticmethod @staticmethod
def args_to_string(*args): def args_to_string(*args):
return "" return ""
@staticmethod @staticmethod
def string_to_args(string): def string_to_args(string):
raise Exception("string_to_args Not Implemented!") raise Exception("string_to_args Not Implemented!")

View File

@ -1,19 +1,26 @@
\documentclass[12pt]{beamer} \documentclass[12pt]{beamer}
\usepackage[english]{babel} \usepackage[english]{babel}
\usepackage{mathtools} \usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{dsfont}
\usepackage{setspace}
\usepackage{tipa}
\usepackage{relsize}
\mode<presentation> \mode<presentation>
{ {
\usetheme{default} % or try Darmstadt, Madrid, Warsaw, ... \usetheme{default} % or try Darmstadt, Madrid, Warsaw, ...
\usecolortheme{default} % or try albatross, beaver, crane, ... \usecolortheme{default} % or try albatross, beaver, crane, ...
\usefonttheme[onlymath]{serif} % or try serif, structurebold, ... \usefonttheme{serif} % or try serif, structurebold, ...
\setbeamertemplate{navigation symbols}{} \setbeamertemplate{navigation symbols}{}
\setbeamertemplate{caption}[numbered] \setbeamertemplate{caption}[numbered]
} }
\begin{document} \begin{document}
\centering
\begin{frame} \begin{frame}
\centering
SizeHere SizeHere
\begin{align*} \begin{align*}
YourTextHere YourTextHere

View File

@ -1,20 +1,27 @@
\documentclass[12pt]{beamer} \documentclass[12pt]{beamer}
\usepackage[english]{babel} \usepackage[english]{babel}
\usepackage{mathtools} \usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{dsfont}
\usepackage{setspace}
\usepackage{tipa}
\usepackage{relsize}
\mode<presentation> \mode<presentation>
{ {
\usetheme{default} % or try Darmstadt, Madrid, Warsaw, ... \usetheme{default} % or try Darmstadt, Madrid, Warsaw, ...
\usecolortheme{default} % or try albatross, beaver, crane, ... \usecolortheme{default} % or try albatross, beaver, crane, ...
\usefonttheme[onlymath]{serif} % or try serif, structurebold, ... \usefonttheme{serif} % or try serif, structurebold, ...
\setbeamertemplate{navigation symbols}{} \setbeamertemplate{navigation symbols}{}
\setbeamertemplate{caption}[numbered] \setbeamertemplate{caption}[numbered]
} }
\begin{document} \begin{document}
\begin{frame} \begin{frame}
\centering
SizeHere SizeHere
YourTextHere YourTextHere
\end{frame} \end{frame}
\end{document} \end{document}

View File

@ -225,7 +225,7 @@ class Bubble(Mobject):
class SpeechBubble(Bubble): class SpeechBubble(Bubble):
DEFAULT_CONFIG = { DEFAULT_CONFIG = {
"initial_width" : 4, "initial_width" : 4,
"initial_height" : 2, "initial_height" : 2,
} }
@ -257,9 +257,9 @@ class SpeechBubble(Bubble):
class ThoughtBubble(Bubble): class ThoughtBubble(Bubble):
DEFAULT_CONFIG = { DEFAULT_CONFIG = {
"num_bulges" : 7, "num_bulges" : 7,
"initial_inner_radius" : 1.8, "initial_inner_radius" : 1.8,
"initial_width" : 6 "initial_width" : 6,
} }
def __init__(self, **kwargs): def __init__(self, **kwargs):
Bubble.__init__(self, **kwargs) Bubble.__init__(self, **kwargs)

View File

@ -29,10 +29,10 @@ class FunctionGraph(Mobject1D):
class ParametricFunction(Mobject): class ParametricFunction(Mobject):
DEFAULT_CONFIG = { DEFAULT_CONFIG = {
"color" : WHITE, "color" : WHITE,
"dim" : 1, "dim" : 1,
"expected_measure" : 10.0, "expected_measure" : 10.0,
"density" : None "density" : None
} }
def __init__(self, function, **kwargs): def __init__(self, function, **kwargs):
self.function = function self.function = function

View File

@ -9,8 +9,8 @@ from helpers import *
class Stars(Mobject): class Stars(Mobject):
DEFAULT_CONFIG = { DEFAULT_CONFIG = {
"point_thickness" : 1, "point_thickness" : 1,
"radius" : SPACE_WIDTH, "radius" : SPACE_WIDTH,
"num_points" : 1000, "num_points" : 1000,
} }
def __init__(self, **kwargs): def __init__(self, **kwargs):
digest_config(self, Stars, kwargs) digest_config(self, Stars, kwargs)