This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from manim import * | |
| class PathFinder(MovingCameraScene): | |
| def construct(self): | |
| # thanks ChatGPT | |
| def closest_neighbor(given_point, points): | |
| # Convert points to numpy array for efficient calculations | |
| points_array = np.array(points) | |
| # Calculate Euclidean distance between given_point and all points |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://discord.com/channels/581738731934056449/1214983872413044786/1214983872413044786 | |
| from manim import * | |
| class PathAutoSorted(MovingCameraScene): | |
| def construct(self): | |
| # thanks ChatGPT | |
| def closest_neighbor(given_point, points): | |
| # Convert points to numpy array for efficient calculations | |
| points_array = np.array(points) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://www.reddit.com/r/manim/comments/1b0mkad/help_making_an_animation_for_a_physics_explainer/ | |
| class blocks(Scene): | |
| def construct(self): | |
| height = 5 | |
| tri = Polygon( | |
| [-height*np.tan(30*DEGREES),-3,0], | |
| [height*np.tan(60*DEGREES),-3,0], | |
| [0,height-3,0] | |
| ) | |
| tri.shift(-tri.get_center()[0]*RIGHT) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://discord.com/channels/581738731934056449/1211276254620155954/1211286899474432051 | |
| from manim import * | |
| class roundTex(Scene): | |
| def construct(self): | |
| text = Tex(r"Lorem ipsum uwezi") | |
| radius = 2 | |
| circ = Circle(radius=radius) | |
| arclen = 180*DEGREES | |
| text.scale_to_fit_width(arclen*radius).move_to(ORIGIN, aligned_edge=DL) # wrap around upper half only |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://discord.com/channels/581738731934056449/1207779001041551440/1208377356155097092 | |
| def search_shape_in_text(text:VMobject, shape:VMobject, index=0): | |
| def get_mobject_key(mobject: Mobject) -> int: | |
| mobject.save_state().center().scale_to_fit_height(1) | |
| r = np.array2string(mobject.points, precision=2, | |
| separator=' ', suppress_small=True, threshold=None) | |
| r = r.replace('-0. ', ' 0. ') | |
| mobject.restore() | |
| return hash(r) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class malayalamFont(Scene): | |
| def construct(self): | |
| import requests | |
| import zipfile | |
| import re | |
| import io | |
| from pathlib import Path | |
| a=requests.get("https://github.com/notofonts/noto-fonts/raw/main/hinted/ttf/NotoSerifMalayalam/NotoSerifMalayalam-Regular.ttf") | |
| with open("./fonts/NotoSerifMalayalam-Regular.ttf", mode="wb") as file: | |
| file.write(a.content) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class automaton(Scene): | |
| def construct(self): | |
| template = TexTemplate() | |
| template.add_to_preamble(r"\usepackage{tikz}") | |
| template.add_to_preamble(r"\usetikzlibrary{arrows}") | |
| tex = Tex( | |
| r"""[->,>=stealth',node distance=3cm] | |
| \node[circle,draw] (1) {A}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class smileyFont(Scene): | |
| def construct(self): | |
| import requests | |
| import zipfile | |
| import re | |
| import io | |
| from pathlib import Path | |
| a=requests.get("https://github.com/atelier-anchor/smiley-sans/releases/download/v1.1.1/smiley-sans-v1.1.1.zip") | |
| z = zipfile.ZipFile(io.BytesIO(a.content)) | |
| font_names = [name for name in z.namelist() if re.search('\.ttf$|\.otf$', name)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from __future__ import annotations | |
| from manim import * | |
| from typing import TYPE_CHECKING, Any, Callable, Iterable, Sequence | |
| class semilogx(NumberPlane): | |
| def SIformat(self, value, decimals=0, digits=None, unit=""): | |
| sign = +1 | |
| if value < 0: | |
| sign = -1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from manim import * | |
| class radClone(Scene): | |
| def construct(self): | |
| npl = NumberPlane( | |
| y_range=[-1.5,1.5,0.5], | |
| y_length=8, | |
| x_range=[-16/9*1.5,+16/9*1.5,0.5], | |
| x_length=16/9*8 | |
| ) |