Skip to content

Instantly share code, notes, and snippets.

View uwezi's full-sized avatar

Uwe Zimmermann uwezi

View GitHub Profile
@uwezi
uwezi / 20221004_png.py
Last active March 19, 2023 13:47
[add transparent PNG] How to add a .png image with alpha-channel transparency. #manim #png #opacity
# https://discord.com/channels/581738731934056449/1026723076001509448/1026938943792500776
from manim import *
class transparent(Scene):
def construct(self):
image = ImageMobject("192x192RedPushPinIcon_Scala.png").shift(1.5*UP+1*RIGHT)
circ = Circle().set_fill(opacity=0.7).set_color(BLUE)
self.play(Create(circ))
@uwezi
uwezi / 20221005_default.py
Last active March 19, 2023 13:51
[Default colors] How to set default colors for objects and backgrounds. #manim #color #default
# by Benjamin Hackl
# https://discord.com/channels/581738731934056449/1027162523738316810/1027208683953852506
from manim import *
config.background_color = WHITE
VMobject.set_default(stroke_color=BLUE)
class test(Scene):
def construct(self):
@uwezi
uwezi / 20230306_riemann.py
Last active March 19, 2023 19:50
[animated Riemann rectangles] Changing the width of Riemann rectangles with ValueTracker() #manim #riemann #plot #valuetracker #animate
# https://discord.com/channels/581738731934056449/1082338919548461086/1082383346912481350
from manim import *
class Graphing(Scene):
def construct(self):
plane = (
NumberPlane(x_range=[-4,4,2], x_length = 7, y_range = [0,16,4], y_length=5)
.to_edge(DOWN)
@uwezi
uwezi / 20221005_colortex.py
Last active July 13, 2023 18:55
[Manually coloring equations] How to manually give different colors to different parts of a MathTex() object. #manim #latex #color
# https://discord.com/channels/581738731934056449/1027291079466287277/1027306410259779694
from manim import *
class colorTex(Scene):
def construct(self):
mathtex = MathTex(*r'f(x) = \ln( x^2 + 3 x + 2 )'.split(' '))
colors =[RED,YELLOW,PURPLE,GREEN,BLUE]
self.play(Write(mathtex))
self.wait(1)
@uwezi
uwezi / 20221006_3dlabels.py
Last active March 24, 2023 22:10
[Custom labels on 3D-axis] Placing custom labels on the ticks of an axis in a 3D-scene. #manim #3D #labels #axes
# https://discord.com/channels/581738731934056449/1027548036349558804/1027642943529549915
from manim import *
class graph5(ThreeDScene):
def construct(self):
ax3d = ThreeDAxes(
x_range=[-10, 10, 1],
y_range=[-5, 5, 1],
z_range=[-5, 5, 1],
@uwezi
uwezi / 20221006_movealong.py
Last active March 19, 2023 20:46
[move along a path] Using the animation MoveAlongPath on a circle. #manim #movealongpath #animate
# https://discord.com/channels/581738731934056449/1027663989511032933/1027668187157889074
from manim import *
class onCircle(Scene):
def construct(self):
circle = Circle()
self.add(circle)
dot = Dot()
@uwezi
uwezi / 20221006_braced.py
Last active March 19, 2023 20:50
[brace with indicated length] Show the length of a brace. #manim #brace #bracebetweenpoints
# https://discord.com/channels/581738731934056449/1027687086792392744/1027694582349189130
from manim import *
class embrace(Scene):
def construct(self):
for i in range(5):
sx = np.random.uniform(low=-5,high=5)
sy = np.random.uniform(low=-3,high=3)
ex = np.random.uniform(low=-5,high=5)
@uwezi
uwezi / 20221008_emoji_github.py
Last active March 19, 2023 21:20
[loading emojis from github] Accessing the openmoji github repo. #manim #png #web
# from @kolibril13
# https://discord.com/channels/581738731934056449/1028242686563590194/1028369092513636362
from manim import *
from PIL import Image
import numpy as np
import requests
class EmojiImageMobject(ImageMobject):
def __init__(self, emoji, **kwargs):
@uwezi
uwezi / 20221009_taylor.py
Last active March 19, 2023 21:29
[Taylor series, polynomial approximation] Approximating exp(x) using a polynom. #manim #math #plot #polynom #animate
# https://discord.com/channels/581738731934056449/1028643327639289897/1028653486864334939
from manim import *
import math
class plots(Scene):
# This scene illustrates the definition of exp(x) by showing the different polynomial expansions
def term(self, x , i):
# returns the i-th term of the Taylor expansion of exp(x) in the variable x
@uwezi
uwezi / 20221011_rotline.py
Last active March 19, 2023 21:35
[rotating line with value of angle] Showing the rotation angle of a line. #manim #line #decimalnumber #valuetracker #animate
# https://discord.com/channels/581738731934056449/1029099371054243871/1029445921496383568
from manim import *
class rotline(Scene):
def construct(self):
vt = ValueTracker(0)
origline = Line(start=ORIGIN, end=2*RIGHT)
line = origline.copy()
dec = DecimalNumber(vt.get_value(), num_decimal_places=0, unit="^o").next_to(line.get_end(), UP)