restore three_d_scene and svgs

This commit is contained in:
Devin Neal 2018-12-26 22:27:11 -08:00
parent 3488d11be3
commit 7e3c30d8f9
4 changed files with 154 additions and 2 deletions

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 480 480" style="enable-background:new 0 0 480 480;" xml:space="preserve">
<style type="text/css">
.st0{fill:#FFFFFF;stroke:#000000;stroke-miterlimit:10;}
.st1{fill:none;stroke:#000000;stroke-miterlimit:10;}
</style>
<path class="st1" d="M220.1,222.2l-93.9,73.6l127.4-70.5c3.4,0.1,6.8,0.2,10.2,0.2c90.3,0,163.5-40.5,163.5-90.4
s-73.2-90.4-163.5-90.4S100.3,85.1,100.3,135C100.3,176.6,151,211.6,220.1,222.2L220.1,222.2z"/>
</svg>

After

Width:  |  Height:  |  Size: 716 B

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 480 480" style="enable-background:new 0 0 480 480;" xml:space="preserve">
<style type="text/css">
.st0{fill:#FFFFFF;stroke:#000000;stroke-miterlimit:10;}
.st1{fill:none;stroke:#000000;stroke-miterlimit:10;}
</style>
<circle class="st1" cx="143.8" cy="268" r="22.6"/>
<circle class="st1" cx="111.8" cy="313.2" r="13.2"/>
<circle class="st1" cx="80.7" cy="334.2" r="7"/>
<path class="st1" d="M293.8,49.9c3-1,6.4-1.9,9.7-1.9c16.8,0,30.4,13.6,30.4,30.4c0,1.9-0.2,3.7-0.5,5.5l0,0
c10.8,4.5,21,16.2,20.5,28.6c-0.4,9.1-1.2,18.8-11.3,27.7l0,0c8.5,6.8,8.7,29.6,4.7,39c-4.1,9.7-11.8,19.6-33.4,27.2
c-8.2,19.4-30.1,35.7-52.4,35.7c-9.6,0-18.9-2.5-26.7-6.9l0,0c-8.1,5.6-17.7,8.8-28.3,8.8c-18.9,0-35.8-10.6-44.4-26l0,0
c-22.5,0-45.3-15.3-49.5-36.6l0,0c-19.2-5.7-33.1-23.4-33.1-44.5c0-9.7,2.9-18.7,8-26.2l0,0c-2.7-5.5-4.2-11.8-4.2-18.3
c0-21.9,17.3-40,38.8-41.6l0,0c7.3-14.6,22.4-24.7,39.9-24.7c4.8,0,9.3,0.7,13.6,2.1l0,0c7.6-8.3,18.7-13.5,30.9-13.5
c12.8,0,24.2,5.7,31.9,14.8l0,0c6-4.7,13.6-7.6,21.7-7.6C277,22.1,290.5,33.9,293.8,49.9L293.8,49.9z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 480 480" style="enable-background:new 0 0 480 480;" xml:space="preserve">
<style type="text/css">
.st0{fill:#FFFFFF;}
.st1{fill:#0C7F99;}
</style>
<path class="st0" d="M251.6,114.7c0,4.2-1.4,8.2-3.7,11.3l-30.4,0.3c-2.6-3.1-4-7.3-4-11.6c0-10.5,8.5-19,19-19
C243.1,95.6,251.6,104.2,251.6,114.7z"/>
<path class="st0" d="M306.6,114.7c0,4.2-1.4,8.2-3.7,11.3l-30.4,0.3c-2.6-3.1-4-7.3-4-11.6c0-10.5,8.5-19,19-19
C298.1,95.6,306.6,104.2,306.6,114.7z"/>
<path d="M238,99.8c-1.3,0.1-2.3,1.1-2.3,2.4c0,1.3,1.1,2.4,2.4,2.4c1.3,0,2.4-1.1,2.4-2.4c0-1.3-1.1-2.4-2.4-2.4
C238.1,99.8,238,99.8,238,99.8l2.9-1c4.3,0,7.7,3.5,7.7,7.7s-3.5,7.7-7.7,7.7s-7.7-3.5-7.7-7.7s3.5-7.7,7.7-7.7"/>
<path d="M293,99.8c-1.3,0.1-2.3,1.1-2.3,2.4c0,1.3,1.1,2.4,2.4,2.4s2.4-1.1,2.4-2.4c0-1.3-1.1-2.4-2.4-2.4
C293.1,99.8,293,99.8,293,99.8l2.9-1c4.3,0,7.7,3.5,7.7,7.7s-3.5,7.7-7.7,7.7s-7.7-3.5-7.7-7.7s3.5-7.7,7.7-7.7"/>
<path class="st1" d="M228.4,157.1h64.4c-15.4,63.8-25.1,105.4-25.1,151c0,8,0,69.5,23.4,69.5c12,0,22.2-10.8,22.2-20.5
c0-2.8,0-4-4-12.5c-15.4-39.3-15.4-88.3-15.4-92.3c0-3.4,0-43.9,12-95.1h63.8c7.4,0,26.2,0,26.2-18.2c0-12.5-10.8-12.5-21.1-12.5
H187.4c-13.1,0-32.5,0-58.7,27.9c-14.8,16.5-33,46.7-33,50.1s2.8,4.6,6.3,4.6c4,0,4.6-1.7,7.4-5.1c29.6-46.7,59.2-46.7,73.5-46.7
h32.5c-12.5,42.7-26.8,92.3-73.5,192c-4.6,9.1-4.6,10.3-4.6,13.7c0,12,10.3,14.8,15.4,14.8c16.5,0,21.1-14.8,27.9-38.7
c9.1-29.1,9.1-30.2,14.8-53L228.4,157.1"/>
<path d="M246.3,149.1c5.5,0,1.9,0.1,13.5,0c10.3-0.1,12.4-0.1,15.7-0.2c0,0-0.3-3.1-0.3-3.1c-3.7,0.1-9.3,0.2-14.7,0.2
c-3.9,0-8.5,0-14.6,0"/>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -1,14 +1,26 @@
from manimlib.animation.transform import ApplyMethod
from manimlib.camera.three_d_camera import ThreeDCamera
from manimlib.constants import *
from manimlib.constants import DEGREES
from manimlib.constants import PRODUCTION_QUALITY_FRAME_DURATION
from manimlib.continual_animation.update import ContinualGrowValue
from manimlib.mobject.coordinate_systems import ThreeDAxes
from manimlib.mobject.geometry import Line
from manimlib.mobject.three_dimensions import Sphere
from manimlib.mobject.types.vectorized_mobject import VGroup
from manimlib.mobject.types.vectorized_mobject import VectorizedPoint
from manimlib.scene.scene import Scene
from manimlib.utils.config_ops import digest_config
from manimlib.utils.config_ops import merge_config
class ThreeDScene(Scene):
CONFIG = {
"camera_class": ThreeDCamera,
"ambient_camera_rotation": None,
"default_angled_camera_orientation_kwargs": {
"phi": 70 * DEGREES,
"theta": -135 * DEGREES,
}
}
def set_camera_orientation(self, phi=None, theta=None, distance=None, gamma=None):
@ -21,7 +33,7 @@ class ThreeDScene(Scene):
if gamma is not None:
self.camera.set_gamma(gamma)
def begin_ambient_camera_rotation(self, rate=0.05):
def begin_ambient_camera_rotation(self, rate=0.02):
self.ambient_camera_rotation = ContinualGrowValue(
self.camera.theta_tracker,
rate=rate
@ -85,3 +97,90 @@ class ThreeDScene(Scene):
def remove_fixed_in_frame_mobjects(self, *mobjects):
self.camera.remove_fixed_in_frame_mobjects(*mobjects)
##
def set_to_default_angled_camera_orientation(self, **kwargs):
config = dict(self.default_camera_orientation_kwargs)
config.update(kwargs)
self.set_camera_orientation(**config)
class SpecialThreeDScene(ThreeDScene):
CONFIG = {
"cut_axes_at_radius": True,
"camera_config": {
"should_apply_shading": True,
"exponential_projection": True,
},
"three_d_axes_config": {
"num_axis_pieces": 1,
"number_line_config": {
"unit_size": 2,
"tick_frequency": 1,
"numbers_with_elongated_ticks": [0, 1, 2],
"stroke_width": 2,
}
},
"sphere_config": {
"radius": 2,
"resolution": (24, 48),
},
"default_angled_camera_position": {
"phi": 70 * DEGREES,
"theta": -110 * DEGREES,
},
# When scene is extracted with -l flag, this
# configuration will override the above configuration.
"low_quality_config": {
"camera_config": {
"should_apply_shading": False,
},
"three_d_axes_config": {
"num_axis_pieces": 1,
},
"sphere_config": {
"resolution": (12, 24),
}
}
}
def __init__(self, **kwargs):
digest_config(self, kwargs)
if self.frame_duration == PRODUCTION_QUALITY_FRAME_DURATION:
config = {}
else:
config = self.low_quality_config
ThreeDScene.__init__(self, **merge_config([kwargs, config]))
def get_axes(self):
axes = ThreeDAxes(**self.three_d_axes_config)
for axis in axes:
if self.cut_axes_at_radius:
p0 = axis.main_line.get_start()
p1 = axis.number_to_point(-1)
p2 = axis.number_to_point(1)
p3 = axis.main_line.get_end()
new_pieces = VGroup(
Line(p0, p1), Line(p1, p2), Line(p2, p3),
)
for piece in new_pieces:
piece.shade_in_3d = True
new_pieces.match_style(axis.pieces)
axis.pieces.submobjects = new_pieces.submobjects
for tick in axis.tick_marks:
tick.add(VectorizedPoint(
1.5 * tick.get_center(),
))
return axes
def get_sphere(self, **kwargs):
config = merge_config([kwargs, self.sphere_config])
return Sphere(**config)
def get_default_camera_position(self):
return self.default_angled_camera_position
def set_camera_to_default_position(self):
self.set_camera_orientation(
**self.default_angled_camera_position
)