ManimCommunity 设置背景颜色
flyfish
主要是这句
self.camera.background_color = WHITE
完整代码
class OpeningManim(Scene):def construct(self):self.camera.background_color = WHITE title = Tex(r"This is some \LaTeX")basel = MathTex(r"\sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}")VGroup(title, basel).arrange(DOWN)self.play(Write(title),FadeIn(basel, shift=DOWN),)self.wait()transform_title = Tex("That was a transform")transform_title.to_corner(UP + LEFT)self.play(Transform(title, transform_title),LaggedStart(*(FadeOut(obj, shift=DOWN) for obj in basel)),)self.wait()grid = NumberPlane()grid_title = Tex("这是一个网格",font_size=72,tex_template=TexTemplateLibrary.ctex)grid_title.move_to(transform_title)self.add(grid, grid_title) # Make sure title is on top of gridself.play(FadeOut(title),FadeIn(grid_title, shift=UP),Create(grid, run_time=3, lag_ratio=0.1),)self.wait()grid_transform_title = Tex(r"That was a non-linear function \\ applied to the grid",)grid_transform_title.move_to(grid_title, UL)grid.prepare_for_nonlinear_transform()self.play(grid.animate.apply_function(lambda p: p+ np.array([np.sin(p[1]),np.sin(p[0]),0,],),),run_time=3,)self.wait()self.play(Transform(grid_title, grid_transform_title))self.wait()
其他颜色
#FFFFFF
是一种表示颜色的方法,称为十六进制颜色代码(Hex Color Code)。它用于指定网页、图形软件以及编程环境中颜色的红(Red)、绿(Green)、蓝(Blue)成分。这种颜色代码以 #
开头,后面跟着六个十六进制数字(0-9 和 A-F),这六个字符是成对出现的,每一对代表红色、绿色和蓝色中的一种颜色分量。
具体来说:
- 第一和第二位(FF)代表红色(Red)的强度,
- 第三和第四位(FF)代表绿色(Green)的强度,
- 第五和第六位(FF)代表蓝色(Blue)的强度。
每个颜色分量可以取 00 到 FF 的值,其中 00
表示没有该颜色,FF
(等于十进制的255)表示该颜色的最大强度。
因此,#FFFFFF
意味着红色、绿色和蓝色都设置为最大值(255),当三种基本色光全部以最大强度混合时,结果得到的是白色(White)。所以 #FFFFFF
代表的是纯白色。
同样地,#000000
会表示黑色,因为所有颜色分量都设置为最小值(0),而其他组合如 #FF0000
代表纯红色,#00FF00
代表纯绿色,#0000FF
代表纯蓝色等等。通过改变这些值,可以创建出几乎所有可见的颜色。
WHITE = ManimColor("#FFFFFF")
GRAY_A = ManimColor("#DDDDDD")
GREY_A = ManimColor("#DDDDDD")
GRAY_B = ManimColor("#BBBBBB")
GREY_B = ManimColor("#BBBBBB")
GRAY_C = ManimColor("#888888")
GREY_C = ManimColor("#888888")
GRAY_D = ManimColor("#444444")
GREY_D = ManimColor("#444444")
GRAY_E = ManimColor("#222222")
GREY_E = ManimColor("#222222")
BLACK = ManimColor("#000000")
LIGHTER_GRAY = ManimColor("#DDDDDD")
LIGHTER_GREY = ManimColor("#DDDDDD")
LIGHT_GRAY = ManimColor("#BBBBBB")
LIGHT_GREY = ManimColor("#BBBBBB")
GRAY = ManimColor("#888888")
GREY = ManimColor("#888888")
DARK_GRAY = ManimColor("#444444")
DARK_GREY = ManimColor("#444444")
DARKER_GRAY = ManimColor("#222222")
DARKER_GREY = ManimColor("#222222")
BLUE_A = ManimColor("#C7E9F1")
BLUE_B = ManimColor("#9CDCEB")
BLUE_C = ManimColor("#58C4DD")
BLUE_D = ManimColor("#29ABCA")
BLUE_E = ManimColor("#236B8E")
PURE_BLUE = ManimColor("#0000FF")
BLUE = ManimColor("#58C4DD")
DARK_BLUE = ManimColor("#236B8E")
TEAL_A = ManimColor("#ACEAD7")
TEAL_B = ManimColor("#76DDC0")
TEAL_C = ManimColor("#5CD0B3")
TEAL_D = ManimColor("#55C1A7")
TEAL_E = ManimColor("#49A88F")
TEAL = ManimColor("#5CD0B3")
GREEN_A = ManimColor("#C9E2AE")
GREEN_B = ManimColor("#A6CF8C")
GREEN_C = ManimColor("#83C167")
GREEN_D = ManimColor("#77B05D")
GREEN_E = ManimColor("#699C52")
PURE_GREEN = ManimColor("#00FF00")
GREEN = ManimColor("#83C167")
YELLOW_A = ManimColor("#FFF1B6")
YELLOW_B = ManimColor("#FFEA94")
YELLOW_C = ManimColor("#FFFF00")
YELLOW_D = ManimColor("#F4D345")
YELLOW_E = ManimColor("#E8C11C")
YELLOW = ManimColor("#FFFF00")
GOLD_A = ManimColor("#F7C797")
GOLD_B = ManimColor("#F9B775")
GOLD_C = ManimColor("#F0AC5F")
GOLD_D = ManimColor("#E1A158")
GOLD_E = ManimColor("#C78D46")
GOLD = ManimColor("#F0AC5F")
RED_A = ManimColor("#F7A1A3")
RED_B = ManimColor("#FF8080")
RED_C = ManimColor("#FC6255")
RED_D = ManimColor("#E65A4C")
RED_E = ManimColor("#CF5044")
PURE_RED = ManimColor("#FF0000")
RED = ManimColor("#FC6255")
MAROON_A = ManimColor("#ECABC1")
MAROON_B = ManimColor("#EC92AB")
MAROON_C = ManimColor("#C55F73")
MAROON_D = ManimColor("#A24D61")
MAROON_E = ManimColor("#94424F")
MAROON = ManimColor("#C55F73")
PURPLE_A = ManimColor("#CAA3E8")
PURPLE_B = ManimColor("#B189C6")
PURPLE_C = ManimColor("#9A72AC")
PURPLE_D = ManimColor("#715582")
PURPLE_E = ManimColor("#644172")
PURPLE = ManimColor("#9A72AC")
PINK = ManimColor("#D147BD")
LIGHT_PINK = ManimColor("#DC75CD")
ORANGE = ManimColor("#FF862F")
LIGHT_BROWN = ManimColor("#CD853F")
DARK_BROWN = ManimColor("#8B4513")
GRAY_BROWN = ManimColor("#736357")
GREY_BROWN = ManimColor("#736357")# Colors used for Manim Community's logo and bannerLOGO_WHITE = ManimColor("#ECE7E2")
LOGO_GREEN = ManimColor("#87C2A5")
LOGO_BLUE = ManimColor("#525893")
LOGO_RED = ManimColor("#E07A5F")
LOGO_BLACK = ManimColor("#343434")