diff --git a/lightbulb.png b/lightbulb.png new file mode 100644 index 0000000000000000000000000000000000000000..a0289b574408b563b7b58fc4394e6a129f1165a0 Binary files /dev/null and b/lightbulb.png differ diff --git a/video.py b/video.py index 6ee7b463e5f58e0e470298822c57b5108811b633..f847f641f8abb2d9c739992f5974b8e25c1684b5 100644 --- a/video.py +++ b/video.py @@ -1,4 +1,5 @@ from manim import * +from matplotlib.lines import Line2D SCREEN_WIDTH = 14.2 SCREEN_HEIGHT = 8 @@ -101,4 +102,34 @@ class RasterizationTriangleScene(ThreeDScene): class RaytracingScene(Scene): def construct(self): square = Square(side_length=3) - square.shift([1, 1]) + square.shift([1, 1, 0]) + + circle = Circle(radius=1.5) + circle.shift([-3, -2, 0]) + + triangle = Triangle() + triangle.shift([1.5, -3, 0]) + + lightbulb = ImageMobject("lightbulb.png") + lightbulb.shift([-0.75, -3.5, 0]) + self.add(lightbulb) + self.play(Create(square), run_time=0.5) + self.play(Create(circle), run_time=0.5) + self.play(Create(triangle), run_time=0.5) + self.wait(1) + + + light_rays = [ + ([-2, 5, 0], [-2, -0.85, 0]), + ([-2, -0.85, 0], [1.4, -2.2, 0]), + ([1.4, -2.2, 0], [0, -0.5, 0]), + ([0, -0.5, 0], [-0.7, -3.3, 0]) + ] + + for ray in light_rays: + self.play(Create(Line3D(start=ray[0], end=ray[1], color=YELLOW)), run_time=0.5) + + self.wait(3) + + +