Text Customization
Text Parameters#
Paremeters - as mentioned in Manim Community Documentation - are:
-
Constructor : -
Text()
-
Parameters :
-
- float (ex:
1.0
) - Optional
- float (ex:
-
- float (ex:
2.5
) - Optional
- float (ex:
-
color
:- color (ex:
BLUE
) - Optional
- Default : (
WHITE
)
- color (ex:
-
- float (ex:
30
) - Optional
- float (ex:
-
- float (ex:
3.0
) - Optional
- float (ex:
-
font
:- string (ex:
"Consolas"
) - Optional
- string (ex:
-
slant
:- string (ex: ``)
- Optional
-
weight
:- string (ex: ``)
- Optional
-
gradient
:- tuple (ex:
(YELLOW, RED)
) - Optional
- tuple (ex:
-
- integer (ex:
2
) - Optional
- integer (ex:
-
height
:- integer (ex:
4
) - Optional
- integer (ex:
-
width
:- integer (ex:
2
) - Optional
- integer (ex:
-
- bool (ex:
True
) - Optional
- bool (ex:
-
- bool (ex:
False
) - Optional
- bool (ex:
-
- bool (ex:
False
) - Optional
- bool (ex:
-
t2c
:- Dict ({key: value}) (ex:
"word": BLUE
) - key = string, value = string
- Dict ({key: value}) (ex:
-
t2f
:- Dict ({key: value}) (ex:
"word": Ink Free
) - key = string, value = string
- Dict ({key: value}) (ex:
-
t2g
:- Dict ({key: value}) (ex:
"word": (RED, YELLOW)
) - key = string, value = tuple
- Dict ({key: value}) (ex:
-
t2s
:- Dict ({key: value}) (ex:
"word": ITALIC
) - key = string, value = string
- Dict ({key: value}) (ex:
-
t2w
:- Dict ({key: value}) (ex:
"word": BOLD
) - key = string, value = string
- Dict ({key: value}) (ex:
Change (Font / Color / Slant / Weight)#
from manimlib import *
class TextExample(Scene):
def construct(self):
text = Text("""Manim Text Example""", font="Consolas", font_size=50, t2c={"Text": BLUE},
t2f={"Text": "Ink Free"})
self.play(Write(text))
self.wait(2)
self.play(FadeOut(text))
text2 = Text("""Font / Color / Slant / Weight""", font="Consolas", font_size=50,
t2c={"Color": RED}, t2f={"Font": "Ink Free"}, t2s={"Slant": ITALIC}, t2w={"Weight": BOLD},)
self.play(Write(text2))
self.wait(3)
self.play(FadeOut(text2))
from manim import *
class TextExample(Scene):
def construct(self):
text = Text("""Manim Text Example""", font="Consolas", font_size=50, t2c={"Text": BLUE},
t2f={"Text": "Ink Free"})
self.play(Write(text))
self.wait(2)
self.play(FadeOut(text))
text2 = Text("""Font / Color / Slant / Weight""", font="Consolas", font_size=50,
t2c={"Color": RED}, t2f={"Font": "Ink Free"}, t2s={"Slant": ITALIC}, t2w={"Weight": BOLD},)
self.play(Write(text2))
self.wait(3)
self.play(FadeOut(text2))
Gradient Color#
from manimlib import *
class GradientText(Scene):
def construct(self):
text2 = Text('Gradient Text', gradient=(RED, YELLOW), font="Constantia").scale(3)
self.play(Write(text2))
self.wait(2)
from manim import *
class GradientText(Scene):
def construct(self):
text2 = Text('Gradient Text', gradient=(RED, YELLOW), font="Constantia").scale(3)
self.play(Write(text2))
self.wait(2)
Writing Arabic Text#
from manimlib import *
class ArabicText(Scene):
def construct(self):
arb = Text("صباح الخير", font="Traditional Arabic").scale(3)
self.play(Write(arb))
from manim import *
class ArabicText(Scene):
def construct(self):
arb = Text("صباح الخير", font="Traditional Arabic").scale(3)
self.play(Write(arb))
Setting a Title#
from manimlib import *
class TitleText(Scene):
def construct(self):
title = Title('Title Text')
self.play(Write(title))
self.wait(2)
from manim import *
class TitleText(Scene):
def construct(self):
title = Title('Title Text')
self.play(Write(title))
self.wait(2)
Bulleted List#
from manimlib import *
class BulletedListExample(Scene):
def construct(self):
blist = BulletedList("Item 1", "Item 2", "Item 3").scale(3)
blist.set_color_by_tex("Item 1", RED)
blist.set_color_by_tex("Item 2", YELLOW)
blist.set_color_by_tex("Item 3", BLUE)
self.play(Write(blist))
self.wait(3)
from manim import *
class BulletedListExample(Scene):
def construct(self):
blist = BulletedList("Item 1", "Item 2", "Item 3", height=4, width=3)
blist.set_color_by_tex("Item 1", RED)
blist.set_color_by_tex("Item 2", YELLOW)
blist.set_color_by_tex("Item 3", BLUE)
self.play(Write(blist))
self.wait(3)