Open martinetss opened 4 years ago
I have installed the version of February 3, 2019. I do not know why the error shown on the screen is due. Could anyone help me please.
I see no method with the name align_with_equal. Which class do you believe has that method?
This is the source code; As I said the error is generated from line 108 that I attach in the image after the source code.
from big_ol_pile_of_manim_imports import *
# class Perpsymb(Rectangle):
# __ini__(self, angle, point):
# perpsym1 = Rectangle(height= .1, width= .1, color =BLUE_B,stroke_width=.5, fill_opacity = 1)
class Scene1(Scene):
CONFIG={
"camera_config":{"background_color":"#181818"},
# "polygon_config":{"color":"WHITE"}
# "color":WHITE
}
def play_line(self, line):
self.add_sound("draw")
self.play(ShowCreation(line))
self.wait(0.1)
def play_point(self, point):
magenta = Color("#FF00FF")
self.play(GrowFromCenter(point),Write(point.label))
self.add_sound("bloop")
self.play(Flash(point,color=magenta))
self.wait(0.1)
def play_transform_eq(self, tex1,tex2):
self.play(Transform(
tex1[:tex1.index_of_part_by_tex("=")],tex2[:tex2.index_of_part_by_tex("=")]
),
Transform(
tex1[tex1.index_of_part_by_tex("=")+1:], tex2[tex2.index_of_part_by_tex("=")+1:]
)
)
def construct(self):
magenta = Color("#FF00FF")
# grid=ScreenGrid()
# self.add(grid)
nodeO = 2.5*LEFT
nodeA = 6*LEFT
nodeB = 1*RIGHT
nodeC = 0.75*LEFT+1.75*UP
nodeD = 0.845*RIGHT+1.03*UP
nodeE = 3.94*LEFT+3.19*UP
nodeF = 4.9749*LEFT+2.4749*DOWN
nodeG = 0.0251*LEFT+2.4749*UP
pointO = Dot(nodeO, color= magenta)
pointO.label = TextMobject("O").next_to(pointO,DR,buff=0.1).scale(.75)
pointA = Dot(nodeA, color= magenta)
pointA.label = TextMobject("A").next_to(pointA,LEFT,buff=0.1).scale(.75)
pointB = Dot(nodeB, color= magenta)
pointB.label = TextMobject("B").next_to(pointB,RIGHT,buff=0.1).scale(.75)
pointC = Dot(nodeC, color= magenta)
pointC.label = TextMobject("C").next_to(pointC,UR,buff=0.05).scale(.75)
pointD = Dot(nodeD, color= magenta)
pointD.label = TextMobject("D").next_to(pointD,RIGHT,buff=0.1).scale(.75)
pointE = Dot(nodeE, color= magenta)
pointE.label = TextMobject("E").next_to(pointE,UL,buff=0.05).scale(.75)
pointF = Dot(nodeF, color= magenta)
pointF.label = TextMobject("F").next_to(pointF,DL,buff=0.05).scale(.75)
pointG = Dot(nodeG, color= magenta)
pointG.label = TextMobject("G").next_to(pointG,UR,buff=0.05).scale(.75)
arc_top = Arc(math.pi, radius=3.5, arc_center = nodeO)
arc_bottom = Arc(math.pi,start_angle=math.pi, radius=3.5, arc_center = nodeO)
line1 = Line(nodeO,nodeA, color=YELLOW)
line1.label = TextMobject("6",color = YELLOW).next_to(line1,DOWN,buff=0.1).scale(.75)
line2 = Line(nodeO,nodeB, color=YELLOW)
line2.label = TextMobject("6",color = YELLOW).next_to(line2,DOWN,buff=0.1).scale(.75)
line3 = Line(nodeO,nodeC, color=GREEN)
line3.label = TexMobject("y",color = GREEN).next_to(0.5*(line3.start + line3.end),LEFT,buff=0.1).scale(.75)
line4 = Line(nodeB,nodeC, color=GREEN)
line4.label = TexMobject("y",color = GREEN).next_to(0.5*(line4.start + line4.end),LEFT,buff=0.2).scale(.75)
line5 = Line(nodeC,nodeE, color=YELLOW)
line5.label = TextMobject("6",color = YELLOW).next_to(0.5*(line5.start + line5.end),DOWN,buff=0.1).scale(.75)
line6 = Line(nodeC,nodeD, color=ORANGE)
line6.label = TexMobject("x",color = ORANGE).next_to(0.5*(line6.start + line6.end),UP,buff=0.1).scale(.75)
line7 = Line(nodeO,nodeF, color=YELLOW)
line7.label = TextMobject("6",color = YELLOW).next_to(0.5*(line7.start + line7.end),RIGHT,buff=0.1).scale(.75)
line8 = Line(nodeC,nodeG, color=WHITE)
line8.label = TexMobject("6-","y",color = WHITE).next_to(0.5*(line8.start + line8.end),RIGHT,buff=0.1).scale(.75).set_color_by_tex("y",GREEN)
points = VGroup(pointO, pointA, pointB, pointC, pointD, pointE, pointF, pointG)
points.labels = VGroup(pointO.label, pointA.label, pointB.label, pointC.label, pointD.label, pointE.label, pointF.label, pointG.label)
lines = VGroup(line1, line2, line3, line4, line5, line6, line7, line8)
lines.lables = VGroup(line1.label,
line5.label,
line6.label,
line7.label,
line8.label)
text_target = TexMobject(r"\text{Hallar }", "x").scale(0.75).move_to(3.5*RIGHT+3*UP)
text_target[1].set_color(ORANGE)
tex_prop_string = TextMobject(r"Teorema de las cuerdas\\ FG y ED").scale(0.75).move_to(text_target.get_center()+DOWN+0.5*RIGHT)
tex_prop_string.fr = SurroundingRectangle(tex_prop_string, fill_opacity=0.5, stroke_width=0, fill_color=BLUE,corner_radius=1)
eq_string1 = TexMobject(r"(","6","+","y",")","\cdot","(","6","-","y",")","=","6","\cdot","x").scale(0.75).move_to(tex_prop_string.get_center()+DOWN).set_color_by_tex("x",ORANGE).set_color_by_tex("y",GREEN).set_color_by_tex("y",GREEN)
eq_string1.v2 = TexMobject(r"36","-","y","^2","=","6","x").scale(0.75).align_with_equal(eq_string1, 0).set_color_by_tex("x",ORANGE).set_color_by_tex("y",GREEN).set_color_by_tex("y",GREEN)
eq_string1.v3 = TexMobject(r"36","-","18","=","6","x").scale(0.75).align_with_equal(eq_string1, 0).set_color_by_tex("x",ORANGE).set_color_by_tex("y",GREEN).set_color_by_tex("y",GREEN)
eq_string1.v4 = TexMobject(r"6","x","=","18").scale(0.75).align_with_equal(eq_string1, 0).set_color_by_tex("x",ORANGE).set_color_by_tex("y",GREEN).set_color_by_tex("y",GREEN)
eq_string1.v5 = TexMobject(r"x","=","{18","\over","6}").scale(0.75).align_with_equal(eq_string1, 0).set_color_by_tex("x",ORANGE).set_color_by_tex("y",GREEN).set_color_by_tex("y",GREEN)
eq_string1.v6 = TexMobject(r"x","=","3").scale(0.75).align_with_equal(eq_string1, 0).set_color_by_tex("x",ORANGE).set_color_by_tex("y",GREEN).set_color_by_tex("y",GREEN)
tex_pita_theo = TextMobject(r"Teorema de pit\'agoras\\ $\triangle OBC$").scale(0.75).move_to(tex_prop_string.get_center()+DOWN)
tex_pita_theo.fr = SurroundingRectangle(tex_pita_theo, fill_opacity=0.5, stroke_width=0, fill_color=BLUE,corner_radius=1)
eq_pita_teho = TexMobject(r"y","^2","+","y","^2","=","6","^","2").scale(0.75).move_to(tex_pita_theo.get_center()+DOWN).set_color_by_tex("x",ORANGE).set_color_by_tex("y",GREEN).set_color_by_tex("y",GREEN)
eq_pita_teho.v2 = TexMobject(r"2","y","^2","=","36").scale(0.75).align_with_equal(eq_pita_teho, 0).set_color_by_tex("x",ORANGE).set_color_by_tex("y",GREEN).set_color_by_tex("y",GREEN)
eq_pita_teho.v3 = TexMobject(r"y","^2","=","18").scale(0.75).align_with_equal(eq_pita_teho.v2, 0).set_color_by_tex("x",ORANGE).set_color_by_tex("y",GREEN).set_color_by_tex("y",GREEN)
# print(eq_string1.index_of_part_by_tex("="))
perpsymb1 = Perpsymb(nodeC,line3.get_angle()+math.pi,fill_color=WHITE)
auxgroup1 = VGroup(arc_top, arc_bottom, line1, line2, line4, line1.label, pointA,pointB, pointA.label, pointB.label)
auxgroup1copy=auxgroup1.copy()
# self.play_line(arc_top)
self.add(arc_top)
# self.play_point(pointA)
self.add(pointA,pointA.label)
# self.play_point(pointB)
self.add(pointB,pointB.label)
# self.play_point(pointO)
self.add(pointO,pointO.label)
self.add_foreground_mobjects(pointA,pointB,pointO)
# self.play_line(line1)
self.add(line1)
# self.play(Write(line1.label))
self.add(line1.label)
# self.play_line(line2)
self.add(line2)
# self.add_sound("draw")
# self.play(ShowCreation(line3),ShowCreation(line4))
self.add(line3,line4,pointB,pointO)
# self.play(Write(perpsymb1))
self.add(perpsymb1)
# self.play_point(pointC)
self.add_foreground_mobjects(pointC, pointC.label)
# self.play_line(line5)
self.add(line5)
# self.play(Write(line5.label))
self.add(line5.label)
# self.play_point(pointE)
self.add_foreground_mobjects(pointE,pointE.label)
# self.play_line(line6)
self.add(line6)
# self.play_point(pointD)
self.add_foreground_mobjects(pointD, pointD.label)
# self.play(Write(line6.label))
self.add(line6.label)
# self.play(FadeInFrom(text_target,DOWN))
self.add(text_target)
# self.play_line(arc_bottom)
self.add(arc_bottom)
# self.play_line(line7)
self.add(line7)
# self.play_point(pointF)
self.add_foreground_mobjects(pointF, pointF.label)
# self.play(ApplyMethod(pointC.label.next_to,pointC,UP))
pointC.label.next_to(pointC,UP)
# self.play_line(line8)
self.add(line8)
# line8.set_color(GRAY)
# self.play_point(pointG)
self.add_foreground_mobjects(pointG,pointG.label)
# self.play(ApplyMethod(auxgroup1.set_color,DARK_GRAY))
# auxgroup1.set_color(DARK_GRAY)
# self.play(FadeInFrom (tex_prop_string.fr,DOWN),FadeInFrom (tex_prop_string,DOWN))
self.add(tex_prop_string.fr,tex_prop_string)
# self.play(Write(line7.label))
self.add(line7.label)
# self.play(Write(line3.label))
self.add(line3.label)
# self.play(Write(line8.label))
self.add_foreground_mobjects(line8.label)
# [self.play(Write(word),run_time=0.5) for word in eq_string1]
self.add(eq_string1)
# self.play_transform_eq(
# eq_string1, eq_string1.v2
# )
self.remove(eq_string1)
self.add(eq_string1.v2)
# self.add(line8.label.arrow)
# self.play(Transform(auxgroup1,auxgroup1copy))
# self.play(FadeOut(VGroup(pointG,pointG.label,pointF,pointF.label,tex_prop_string.fr,tex_prop_string,line8,line8.label,line7,line7.label)))
self.remove(pointG,pointG.label,pointF,pointF.label,tex_prop_string.fr,tex_prop_string,line8,line8.label,line7,line7.label)
# self.play(ApplyMethod(eq_string1.v2.move_to,tex_prop_string))
eq_string1.v2.move_to(tex_prop_string)
# self.play(FadeInFrom (tex_pita_theo.fr,DOWN),FadeInFrom (tex_pita_theo,DOWN))
self.add(tex_pita_theo.fr,tex_pita_theo)
# self.play(Write(line4.label))
self.add(line4.label)
# self.play(Write(line2.label))
self.add(line2.label)
# [self.play(Write(word),run_time=0.5) for word in eq_pita_teho]
self.add(eq_pita_teho)
# self.play_transform_eq(
# eq_pita_teho, eq_pita_teho.v2
# )
self.remove(eq_pita_teho)
self.add(eq_pita_teho.v2)
# self.play_transform_eq(
# eq_pita_teho.v2, eq_pita_teho.v3
# )
self.remove(eq_pita_teho.v2)
self.add(eq_pita_teho.v3)
# self.play(FadeOut(tex_pita_theo),FadeOut(tex_pita_theo.fr))
self.remove(tex_pita_theo,tex_pita_theo.fr)
# self.play(ApplyMethod(eq_pita_teho.v3.move_to,tex_pita_theo))
eq_pita_teho.v3.move_to(tex_pita_theo)
eq_string1.v3.align_with_equal(eq_string1.v2,0)
eq_string1.v4.align_with_equal(eq_string1.v2,0)
eq_string1.v5.align_with_equal(eq_string1.v2,0)
eq_string1.v6.align_with_equal(eq_string1.v2,0)
eq_string1.v6.fr = SurroundingRectangle(eq_string1.v6, fill_opacity=0.5, stroke_width=0, fill_color=GREEN,corner_radius=1)
# self.play_transform_eq(
# eq_string1.v2, eq_string1.v3
# )
# self.play(FadeOut(eq_pita_teho.v3))
self.remove(eq_string1.v2)
self.add(eq_string1.v3)
self.remove(eq_pita_teho.v3)
# self.play_transform_eq(
# eq_string1.v3, eq_string1.v4
# )
self.remove(eq_string1.v3)
self.add(eq_string1.v4)
# self.play_transform_eq(
# eq_string1.v4, eq_string1.v5
# )
self.remove(eq_string1.v4)
self.add(eq_string1.v5)
self.play_transform_eq(
eq_string1.v5, eq_string1.v6
)
self.add_foreground_mobjects(eq_string1.v6)
self.play(FadeIn(eq_string1.v6.fr))
# self.remove(eq_string1.v5)
# self.add(eq_string1.v6)
self.wait(.1)
class AudioTest(Scene):
def construct(self):
group_dots=VGroup(*[Dot()for _ in range(3)])
group_dots.arrange_submobjects(RIGHT)
for dot in group_dots:
self.add_sound("click")
self.add(dot)
self.wait()
self.wait()
class SVGTest(Scene):
def construct(self):
svg = SVGMobject("camera")
#svg = SVGMobject("camera")
self.play(DrawBorderThenFill(svg,rate_func=lambda t:-(t**2-t)*4./3))
self.wait()
class ImageTest(Scene):
def construct(self):
image = ImageMobject("note")
self.play(FadeIn(image))
self.wait()
Ok, I don't see any method with that name in any standard manim class. Maybe you've pulled from a different branch than I have.
My question was, what class do you think algin_with_equal is a member of? What effect do you think that function will have?
I can tell you that (after fixing a few other syntax issues) I am able to get your code to run by replacing align_with_equal with align_to. For example, here is my version of your specific line of code which failed:
eq_string1.v2 = TexMobject(r"36","-","y","^2","=","6","x").scale(0.75).align_to(eq_string1).set_color_by_tex("x",ORANGE).set_color_by_tex("y",GREEN).set_color_by_tex("y",GREEN)
eq_string1.v3 = TexMobject(r"36","-","18","=","6","x").scale(0.75).align_to(eq_string1).set_color_by_tex("x",ORANGE).set_color_by_tex("y",GREEN).set_color_by_tex("y",GREEN)
eq_string1.v4 = TexMobject(r"6","x","=","18").scale(0.75).align_to(eq_string1).set_color_by_tex("x",ORANGE).set_color_by_tex("y",GREEN).set_color_by_tex("y",GREEN)
eq_string1.v5 = TexMobject(r"x","=","{18","\over","6}").scale(0.75).align_to(eq_string1).set_color_by_tex("x",ORANGE).set_color_by_tex("y",GREEN).set_color_by_tex("y",GREEN)
eq_string1.v6 = TexMobject(r"x","=","3").scale(0.75).align_to(eq_string1).set_color_by_tex("x",ORANGE).set_color_by_tex("y",GREEN).set_color_by_tex("y",GREEN)
Dear Alexander Williams, I want to thank you for trying to solve it. The animation to obtain is the one shown in the following link: https://www.youtube.com/watch?v=EzBKKmvdY98&t=87s The author of that channel sent me the source code of the animation because of a request I made, but when I ran the code I got this and other errors. I wrote to the author of the animation to tell me what the errors were, but he didn't reply. For this reason, I turn to this community to find a solution.