| from MF_Tools import TransformByGlyphMap | |
| class benzeneAnim(Scene): | |
| def construct(self): | |
| mol1 = Tex( | |
| r"\chemfig{*6(-=-=-=)}", | |
| tex_template=myChemTemplate | |
| ).set_stroke(width=3) | |
| mol2 = Tex( | |
| r"\chemfig{*6(--=-(=O)-=)}", | |
| tex_template=myChemTemplate | |
| ).set_stroke(width=3) | |
| mol2.shift(mol1.get_bottom()-mol2.get_bottom()) | |
| self.play(Create(mol1)) | |
| self.wait() | |
| self.play( | |
| TransformByGlyphMap( | |
| mol1, mol2, | |
| ([0,1,3,4,6,7],[0,1,2,4,8,9]), | |
| ([8],[10]), | |
| (FadeIn,[5], {"shift":5*LEFT}), # oxygen atom | |
| (SpinInFromNothing,[6],{"angle":4*PI}), # left bond | |
| ([2],[3]), | |
| ([5],[7]) | |
| ), | |
| run_time=3, | |
| ) | |
| self.wait() |