Nearly done with fractal dimension project

This commit is contained in:
Grant Sanderson
2017-01-20 09:26:14 -08:00
parent 5174d175cf
commit 27e101ebca
5 changed files with 1188 additions and 24 deletions

View File

@ -146,10 +146,12 @@ class GraphScene(Scene):
proportion = 0.7, proportion = 0.7,
direction = LEFT, direction = LEFT,
buff = MED_BUFF, buff = MED_BUFF,
color = None,
animate = True animate = True
): ):
label = TexMobject(label) label = TexMobject(label)
label.highlight(graph.get_color()) color = color or graph.get_color()
label.highlight(color)
label.next_to( label.next_to(
graph.point_from_proportion(proportion), graph.point_from_proportion(proportion),
direction, direction,

File diff suppressed because it is too large Load Diff

View File

@ -62,7 +62,7 @@ class SVGMobject(VMobject):
result.append(self.rect_to_mobject(element)) result.append(self.rect_to_mobject(element))
elif element.tagName == 'circle': elif element.tagName == 'circle':
result.append(self.circle_to_mobject(element)) result.append(self.circle_to_mobject(element))
elif element.tagName == 'polygon': elif element.tagName in ['polygon', 'polyline']:
result.append(self.polygon_to_mobject(element)) result.append(self.polygon_to_mobject(element))
else: else:
warnings.warn("Unknown element type: " + element.tagName) warnings.warn("Unknown element type: " + element.tagName)

View File

@ -9,7 +9,7 @@ from topics.objects import Bubble, ThoughtBubble, SpeechBubble
from animation import Animation from animation import Animation
from animation.transform import Transform, ApplyMethod, \ from animation.transform import Transform, ApplyMethod, \
FadeOut, FadeIn, ApplyPointwiseFunction FadeOut, FadeIn, ApplyPointwiseFunction, MoveToTarget
from animation.simple_animations import Write, ShowCreation, AnimationGroup from animation.simple_animations import Write, ShowCreation, AnimationGroup
from scene import Scene from scene import Scene
@ -228,6 +228,7 @@ class PiCreatureSays(AnimationGroup):
"change_mode_kwargs" : {}, "change_mode_kwargs" : {},
"bubble_creation_kwargs" : {}, "bubble_creation_kwargs" : {},
"write_kwargs" : {}, "write_kwargs" : {},
"look_at_arg" : None,
} }
def __init__(self, pi_creature, *content, **kwargs): def __init__(self, pi_creature, *content, **kwargs):
digest_config(self, kwargs) digest_config(self, kwargs)
@ -237,21 +238,16 @@ class PiCreatureSays(AnimationGroup):
bubble.pin_to(pi_creature) bubble.pin_to(pi_creature)
pi_creature.bubble = bubble pi_creature.bubble = bubble
pi_creature.generate_target()
pi_creature.target.change_mode(self.target_mode)
if self.look_at_arg:
pi_creature.target.look_at(self.look_at_arg)
AnimationGroup.__init__( AnimationGroup.__init__(
self, self,
ApplyMethod( MoveToTarget(pi_creature, **self.change_mode_kwargs),
pi_creature.change_mode, ShowCreation(bubble, **self.bubble_creation_kwargs),
self.target_mode, Write(bubble.content, **self.write_kwargs),
**self.change_mode_kwargs
),
ShowCreation(
bubble,
**self.bubble_creation_kwargs
),
Write(
bubble.content,
**self.write_kwargs
),
**kwargs **kwargs
) )

View File

@ -28,7 +28,7 @@ def fractalification_iteration(vmobject,
# original_anchors = vmobject.get_anchors() # original_anchors = vmobject.get_anchors()
original_anchors = [ original_anchors = [
vmobject.point_from_proportion(x) vmobject.point_from_proportion(x)
for x in np.linspace(0, 0.99, num_points) for x in np.linspace(0, 1-1./num_points, num_points)
] ]
new_anchors = [] new_anchors = []
for p1, p2, in zip(original_anchors, original_anchors[1:]): for p1, p2, in zip(original_anchors, original_anchors[1:]):
@ -424,6 +424,19 @@ class KochCurve(KochSnowFlake):
} }
class QuadraticKoch(LindenmayerCurve):
CONFIG = {
"colors" : [YELLOW, WHITE, MAROON_B],
"axiom" : "A",
"rule" : {
"A" : "A+A-A-AA+A+A-A"
},
"radius" : 4,
"scale_factor" : 4,
"start_step" : RIGHT,
"angle" : np.pi/2
}
class StellarCurve(LindenmayerCurve): class StellarCurve(LindenmayerCurve):
CONFIG = { CONFIG = {