From c2a67346f9a1b18f6304c47ae25d8ca470432fa5 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Sat, 5 May 2018 20:19:33 -0700 Subject: [PATCH] Added tex_to_color_map abilty to TexMobject config --- mobject/svg/tex_mobject.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mobject/svg/tex_mobject.py b/mobject/svg/tex_mobject.py index 52da3c0e..16eebe7f 100644 --- a/mobject/svg/tex_mobject.py +++ b/mobject/svg/tex_mobject.py @@ -131,6 +131,7 @@ class TexMobject(SingleStringTexMobject): CONFIG = { "arg_separator": " ", "substrings_to_isolate": [], + "tex_to_color_map": {}, } def __init__(self, *tex_strings, **kwargs): @@ -141,13 +142,18 @@ class TexMobject(SingleStringTexMobject): self, self.arg_separator.join(tex_strings), **kwargs ) self.break_up_by_substrings() + self.set_color_by_tex_to_color_map(self.tex_to_color_map) if self.organize_left_to_right: self.organize_submobjects_left_to_right() def break_up_tex_strings(self, tex_strings): + substrings_to_isolate = op.add( + self.substrings_to_isolate, + self.tex_to_color_map.keys() + ) split_list = split_string_list_to_isolate_substring( - tex_strings, *self.substrings_to_isolate + tex_strings, *substrings_to_isolate ) split_list = map(str.strip, split_list) split_list = filter(lambda s: s != '', split_list)