Skip to content

Instantly share code, notes, and snippets.

@abul4fia
abul4fia / ligth_theme.py
Last active May 8, 2025 22:19
Light theme for manim
# Put this file in the same folder than your manim script
# and start your script with:
#
# import light_theme
from manim import *
config.background_color = WHITE
# Those are objects which are WHITE by default
@abul4fia
abul4fia / example.py
Last active April 30, 2024 12:07
Generic formula transformation under control
"""
This is an example which uses the "low-level" interface, specifying
the indexes or slices() that should be transformed one into
another.
"""
class Test(Scene):
def construct(self):
m1 = MathTex(r"\frac{x}{y} = \frac{a}{b}\times5")
self.add(m1)
m2 = MathTex(r"x\cdot b = y\cdot a\times5")
@abul4fia
abul4fia / README.md
Last active July 27, 2024 11:35
Quine in manim

A "Quine" is a program that reproduces its own source code in the standard output when it is run.

There is a trivial way of doing so, such as:

with open("source.py") as f:
    print(f.read())

But this is considered cheating. The code should not read the source file.

@abul4fia
abul4fia / manim_textbox.py
Created June 26, 2023 18:26
Text box for manim
def create_textbox(string, width, height, text_color=BLACK, align=ORIGIN, color=BLUE, buff=0.2):
tex_align = {
tuple(UL): "\\raggedright",
tuple(LEFT): "\\raggedright",
tuple(DL): "\\raggedright",
tuple(UP): "\\centering",
tuple(ORIGIN): "\\centering",
tuple(DOWN): "\\centering",
tuple(UR): "\\raggedleft",
tuple(RIGHT): "\\raggedleft",
@abul4fia
abul4fia / fixed_fixing.py
Created June 20, 2023 07:32
How to fix objects and transforms in a manim 3D scene
# Context:
#
# Although ThreeDScene has the method `self.add_fixed_in_frame_mobjects()`
# it doesnt work as expected if you want to have transforms that happen
# in the frame coordinates, instead of in 3D coordinates
#
# See https://discord.com/channels/581738731934056449/1120217688728424549/1120217688728424549
#
# This fix fixes the fixed objects in a different way that works under transforms
@abul4fia
abul4fia / 00README.md
Last active April 18, 2025 01:32
Working with sections in manim

Working with sections in manim

Manim provides out of the box the possibility of marking parts of your scene as separate sections, by using self.next_section(). This will cause a separate video to be rendered for each section, and then all of them will be stitched together for the final result. The final result will be the same as if you hadn't used sections at all.

But the use of sections allows you to mark some of them with the parameter skip_animations=True, and in that case, that section will not be rendered. The code of the section will be run anyway (because it may be defining objects or variables needed in following sections), but for every self.play(), only the final frame will be computed (and not rendered). This ensures that, at the end of the section, all objects are at the same positions as if the animations were played, but skipping the actual rendering significantly reduces the time required to run the code.

In addition, the resulting video when skip_animations=True is used will be s

@abul4fia
abul4fia / 00README.md
Last active December 20, 2024 21:08
Finding sub-texts by shape in manim

Finding shapes in Tex mobjects

This module implements some utility functions to search some shapes (formulas, symbols) inside a Tex (or MathTex) mobject.

The approach is to compare the shapes (bezier curves) of the symbols, instead of the particular strings that produced them. This approach is generic and avoids the use of other manim mechanisms that would break under some circunstances, such as the presence of \frac{}{} in a formula.

The function you would probably want to use is group_shapes_in_tex(). Despite the confusing name, the goal is to find all the occurences of a given symbol (or group of symbols, or list of symbols) inside a Tex mobject, and return a VGroup containing them

@abul4fia
abul4fia / example.py
Last active December 27, 2024 19:50
Generic sequences of animations run in paralell (for Manim)
from sequences import play_sequence_in_background, join_all
class Test(Scene):
def construct(self):
c = Circle()
sq = Square().to_corner(UR)
seq1 = play_sequence_in_background(self,
[
FadeIn(c, run_time=2),
ApplyMethod(c.shift, 3*RIGHT, run_time=3),
@abul4fia
abul4fia / Flujo de trabajo.md
Last active April 18, 2023 00:24
Planificación tipo GTD con logseq
  • Basado en [[GTD]] y en un video de Youtube de OneStutteringMind, pero ligeramente adaptado por mi.
  • Flujo de trabajo

    • Fase de captura de información

      • Añadir directamente en la agenda las cosas que tenga en la cabeza y no quiera olvidar, con el tag #inbox
      • También se pueden añadir desde el móvil enviando un mensaje a Telegram y usando mi script para descargarlo
    • Fase de análisis (clarify)

      • Se revisan los elementos de la etiqueta #inbox y se mira en qué caso se está:
        • Requiere acción (yo, o alguien, debe hacer algo acerca de este tema, para que cierto proyecto avance)
        • No requiere acción (es material de lectura o aficiones)
    • Fase de Organización

@abul4fia
abul4fia / Planificador
Last active March 13, 2023 00:09
Planificación con Logseq
- ## 🔥 Tareas ==vencidas==
query-table:: false
#+BEGIN_QUERY
{
:query [
:find (pull ?block [*])
:in $ ?today
:where
[?block :block/marker ?m]
[(contains? #{"TODO"} ?m)]