diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..beaaaef --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +__pycache__ +media +slides +Slides_assets +slides.pdf \ No newline at end of file diff --git a/images/announcement.png b/images/announcement.png new file mode 100644 index 0000000..09690ac Binary files /dev/null and b/images/announcement.png differ diff --git a/images/background.png b/images/background.png new file mode 100644 index 0000000..3033adc Binary files /dev/null and b/images/background.png differ diff --git a/images/channel.png b/images/channel.png new file mode 100644 index 0000000..9d5d190 Binary files /dev/null and b/images/channel.png differ diff --git a/images/summer_videos.jpg b/images/summer_videos.jpg new file mode 100644 index 0000000..c2ca316 Binary files /dev/null and b/images/summer_videos.jpg differ diff --git a/images/title.png b/images/title.png new file mode 100644 index 0000000..fd7a6b6 Binary files /dev/null and b/images/title.png differ diff --git a/scenes/animation_a.py b/scenes/animation_a.py new file mode 100644 index 0000000..de91551 --- /dev/null +++ b/scenes/animation_a.py @@ -0,0 +1,58 @@ +from manim import * +from manim_slides import Slide + +from util import text, coordinates + +class AnimationA(Slide): + def __init__(self): + super().__init__() + self.title = "Example (1)" + self.triangle_color = BLUE + + def construct(self, render): + du = 0.2 * DOWN + d1 = Dot(LEFT*4+du) + d2 = Dot(RIGHT*2+du) + d3 = Dot(RIGHT*1+UP*3+du) + + triangle = Polygon( + d1.get_center(),d2.get_center(),d3.get_center(), + color = self.triangle_color, + stroke_width = 8 + ) + render.add(triangle) + + alpha_arc = Angle.from_three_points(d2,d1,d3, color=self.triangle_color) + beta_arc = Angle.from_three_points(d3,d2,d1, color=self.triangle_color) + gamma_arc = Angle.from_three_points(d1,d3,d2, color=self.triangle_color) + + render.add(alpha_arc) + render.add(beta_arc) + render.add(gamma_arc) + + alpha = text.math(r"\alpha").next_to(d1).shift(0.3*RIGHT+0.2*UP) + beta = text.math(r"\beta").next_to(d2, UP).shift(0.4*LEFT) + gamma = text.math(r"\gamma").next_to(d3, DOWN).shift(0.2*DOWN+0.2*LEFT) + angles = VGroup(alpha, beta, gamma) + + render.add(alpha) + render.add(beta) + render.add(gamma) + + render.wait() + render.next_slide() + + equation_1 = text.math(r"\alpha").move_to(2 * DOWN) + equation_2 = text.math(r"\alpha", " + ", r"\beta").move_to(2 * DOWN) + equation_3 = text.math(r"\alpha", " + ", r"\beta", " + ", r"\gamma").move_to(2 * DOWN) + equation_4 = text.math(r"\alpha", " + ", r"\beta", " + ", r"\gamma", r" = 180^\circ").move_to(2 * DOWN) + + render.play(TransformMatchingTex(alpha.copy(), equation_1)) + render.wait() + render.play(TransformMatchingTex(Group(equation_1, beta.copy()), equation_2)) + render.wait() + render.play(TransformMatchingTex(Group(equation_2, gamma.copy()), equation_3)) + render.wait() + render.play(TransformMatchingTex(equation_3, equation_4)) + + render.wait() diff --git a/scenes/animation_b.py b/scenes/animation_b.py new file mode 100644 index 0000000..2bea98d --- /dev/null +++ b/scenes/animation_b.py @@ -0,0 +1,19 @@ +from manim import * +from manim_slides import Slide + +from util import text, coordinates + +class Example(Slide): + def __init__(self): + super().__init__() + self.title = "Example" + + + def construct(self, render): + my_text = text.tex("Test").next_to(coordinates.UPPER_LEFT) + render.add(my_text) + + circle = Circle(radius=2, color=BLUE) + render.add(circle) + + render.wait() \ No newline at end of file diff --git a/scenes/community.py b/scenes/community.py new file mode 100644 index 0000000..13f3c75 --- /dev/null +++ b/scenes/community.py @@ -0,0 +1,28 @@ +from manim import * +from manim_slides import Slide + +from util import text, coordinates + +class Community(Slide): + def __init__(self): + super().__init__() + self.title = "The Manim Community" + + + def construct(self, render): + exposition = ImageMobject( + "images/announcement.png" + ).scale_to_fit_width( + 0.4 * render.camera.frame_width + ).next_to(ORIGIN, LEFT) + + participants = ImageMobject( + "images/summer_videos.jpg" + ).scale_to_fit_width( + 0.4 * render.camera.frame_width + ).next_to(ORIGIN, RIGHT) + + render.add(exposition) + render.add(participants) + + render.wait() \ No newline at end of file diff --git a/scenes/example.py b/scenes/example.py new file mode 100644 index 0000000..2bea98d --- /dev/null +++ b/scenes/example.py @@ -0,0 +1,19 @@ +from manim import * +from manim_slides import Slide + +from util import text, coordinates + +class Example(Slide): + def __init__(self): + super().__init__() + self.title = "Example" + + + def construct(self, render): + my_text = text.tex("Test").next_to(coordinates.UPPER_LEFT) + render.add(my_text) + + circle = Circle(radius=2, color=BLUE) + render.add(circle) + + render.wait() \ No newline at end of file diff --git a/scenes/title.py b/scenes/title.py new file mode 100644 index 0000000..aff6431 --- /dev/null +++ b/scenes/title.py @@ -0,0 +1,37 @@ +from dataclasses import dataclass + +from manim import * +from manim_slides import Slide + +from util import text + +@dataclass +class Title(Slide): + title: str + authors: str + affiliation: str + date: str + + def construct(self, render): + background = ImageMobject("images/title.png") + background.scale_to_fit_height(render.camera.frame_height) + background.scale_to_fit_width(render.camera.frame_width) + render.add(background) + + coordinate_start = 6 * LEFT + 1 * UP + + text_authors = text.tex(self.authors, color = WHITE, font_size=24).next_to(coordinate_start, RIGHT) + text_affiliation = text.tex(self.affiliation, color = WHITE, font_size=24).next_to(text_authors, DOWN, buff=0.35).align_to(text_authors, LEFT) + text_title = text.tex(f'\\textbf{{{self.title}}}', color = WHITE, font_size = 42).next_to(text_affiliation, DOWN, buff=0.35).align_to(text_authors, LEFT) + text_date = text.tex(self.date, color = WHITE, font_size=24).shift(3 * DOWN).align_to(text_authors, LEFT) + + render.add(text_authors) + render.add(text_affiliation) + render.add(text_title) + render.add(text_date) + + render.wait() + + + + diff --git a/scenes/what.py b/scenes/what.py new file mode 100644 index 0000000..8169825 --- /dev/null +++ b/scenes/what.py @@ -0,0 +1,16 @@ +from manim import * +from manim_slides import Slide + +from util import text, coordinates + +class What(Slide): + def __init__(self): + super().__init__() + self.title = "What is Manim?" + + + def construct(self, render): + channel = ImageMobject("images/channel.png").scale_to_fit_width(0.8 * render.camera.frame_width) + render.add(channel) + + render.wait() \ No newline at end of file diff --git a/slides.html b/slides.html new file mode 100644 index 0000000..b2fa954 --- /dev/null +++ b/slides.html @@ -0,0 +1,301 @@ + + + + + + + Manim Slides + + + + + + + + + + + + +
+
+ +
+ +
+
+ + + + + + + + + + + \ No newline at end of file diff --git a/slides.py b/slides.py new file mode 100644 index 0000000..96fe31b --- /dev/null +++ b/slides.py @@ -0,0 +1,70 @@ +from manim import * +from manim_slides import Slide + +from util import text, coordinates + +from scenes import title, what, community, animation_a + +create_title = False + +# Put your slides here +slides = [ + # what.What(), + # community.Community(), + animation_a.AnimationA(), +] + +title_long = "Creating Animated Slides With" +title_short = "Creating Slides With Manim" +authors_long = "Alex Ivliev" +authors_short = "Alex Ivliev" +affiliation = "Knowledge-Based Systems, TU Dresden" +date = "Retreat 2024, 21st of August" + +class Slides(Slide): + def draw_background(render, current, max): + background = ImageMobject("images/background.png") + background.scale_to_fit_height(render.camera.frame_height) + background.scale_to_fit_width(render.camera.frame_width) + render.add(background) + + coordinate_title = 4 * LEFT + 3.45 * DOWN + coordinate_slide = 1.5 * RIGHT + 3.6 * DOWN + coordinate_number = coordinate_slide + 1.0 * RIGHT + + title = text.tex(title_short, color = GRAY, font_size= 18).next_to(coordinate_title, RIGHT) + author = text.tex(authors_short, color = GRAY, font_size= 18).next_to(coordinate_title, RIGHT).shift(0.25 * DOWN) + render.add(title) + render.add(author) + + slides_text = text.tex("Slide", color = GRAY, font_size= 18).next_to(coordinate_slide, RIGHT) + slides_current = text.tex(f'{current}', color = GRAY, font_size= 18).next_to(coordinate_number, LEFT).align_to(coordinate_number, RIGHT) + slides_max = text.tex(f'of {max}', color = GRAY, font_size= 18).next_to(coordinate_number, RIGHT, buff=0.1) + + render.add(slides_max) + render.add(slides_current) + render.add(slides_text) + + def draw_slide_title(render, title): + text_title = text.tex(f'\\textbf{{{title}}}', color = GRAY, font_size=42).next_to(coordinates.UPPER_LEFT + 0.25 * UP, RIGHT, aligned_edge=DOWN) + render.add(text_title) + + def construct(self): + if create_title: + title.Title( + authors = authors_long, + title = title_long, + affiliation = affiliation, + date = date, + ).construct(self) + + for (index, slide) in enumerate(slides): + self.next_slide() + + self.clear() + self.draw_background(index + 1, len(slides)) + self.draw_slide_title(slide.title) + + slide.construct(self) + + self.wait() \ No newline at end of file diff --git a/util/coordinates.py b/util/coordinates.py new file mode 100644 index 0000000..511b99e --- /dev/null +++ b/util/coordinates.py @@ -0,0 +1,6 @@ +from manim import * + +UPPER_LEFT = 6.25 * LEFT + 3 * UP +LOWER_LEFT = 6.25 * LEFT + 3.25 * DOWN +UPPER_RIGHT = 6.25 * RIGHT + 3.25 * UP +LOWER_RIGHT = 6.25 * RIGHT + 3.25 * DOWN \ No newline at end of file diff --git a/util/text.py b/util/text.py new file mode 100644 index 0000000..652c157 --- /dev/null +++ b/util/text.py @@ -0,0 +1,7 @@ +from manim import * + +def tex(text, color = ManimColor(list([0.0, 0.1875, 0.3672])), font_size = 32): + return Tex(text, color=color, tex_template=TexFontTemplates.helvetica_fourier_it, font_size=font_size) + +def math(*text, color = ManimColor(list([0.0, 0.1875, 0.3672])), font_size = 32): + return MathTex(*text, color=color, tex_template=TexFontTemplates.helvetica_fourier_it, font_size=font_size) \ No newline at end of file