from manim import *
config.background_color = WHITE

class urn(Scene):
    def construct(self):
        #group = VGroup(Dot(LEFT), Dot(ORIGIN), Dot(RIGHT, color=RED), Dot(2 * RIGHT)).scale(1.4)
        #dest = Dot([0, 5, 0], color=YELLOW)

        # urne
        line1 = Line([-2.5, 1, 0], [-2.5, -1, 0])
        line1.set_stroke(BLACK, width=2)
        line2 = Line([-2.5, -1, 0], [0.5, -1, 0])
        line2.set_stroke(BLACK, width=2)
        line3 = Line([0.5, -1, 0], [0.5, 1, 0])
        line3.set_stroke(BLACK, width=2)
        self.play(FadeIn(line1),FadeIn(line2),FadeIn(line3))
        self.wait(1)

        dot1 = LabeledDot(MathTex("1", color=WHITE), color=BLACK).scale(1)
        dot2 = LabeledDot(MathTex("2", color=WHITE), color=BLACK).scale(1)
        dot3 = LabeledDot(MathTex("3", color=WHITE), color=BLACK).scale(1)
        dot4 = LabeledDot(MathTex("4", color=WHITE), color=BLACK).scale(1)
        dot5 = LabeledDot(MathTex("n", color=WHITE), color=BLACK).scale(1.075)
        dot6 = LabeledDot(MathTex("", color=WHITE), color=BLACK).scale(2.75)
        dot7 = LabeledDot(MathTex("", color=WHITE), color=BLACK).scale(2.75)
        dot8 = LabeledDot(MathTex("", color=WHITE), color=BLACK).scale(2.75)

        dot1.move_to(LEFT)
        dot2.next_to(dot1, RIGHT)
        dot3.next_to(dot1, LEFT)
        dot4.next_to(dot1, UP)
        dot5.next_to(dot2, UP)
        dot6.move_to([-0.75,-0.65,0])
        dot7.move_to([-0.05,-0.65,0])
        dot8.move_to([-1.5,-0.65,0])
        self.play(FadeIn(dot1), FadeIn(dot2), FadeIn(dot3), FadeIn(dot4), FadeIn(dot5), FadeIn(dot6), FadeIn(dot7), FadeIn(dot8))

        #circle1 = Circle(radius=0.3, color=BLACK, fill_opacity=1)
        #tex1 = MathTex(r"1", color=WHITE).scale(0.5)
        #circle2 = Circle(radius=0.3, color=BLACK, fill_opacity=1)
        #tex2 = MathTex(r"2", color=WHITE).scale(0.5)
        #circle3 = Circle(radius=0.3, color=BLACK, fill_opacity=1)
        #tex3 = MathTex(r"3", color=WHITE).scale(0.5)
        #circle4 = Circle(radius=0.3, color=BLUE_B, fill_opacity=1)
        #circle1.move_to(LEFT)
        #tex1.move_to(LEFT)
        #circle2.next_to(circle1, LEFT)
        #tex2.next_to(circle1, LEFT)
        #circle3.next_to(circle1, RIGHT)
        #tex2.next_to(circle1, RIGHT)
        #circle4.next_to(circle1, UP)

        #circle3 = Circle(radius=0.3, color=BLUE_B, fill_opacity=1)
        #circle3.shift(UP+2*LEFT)
        #circle4 = Circle(radius=0.3, color=BLUE_B, fill_opacity=1)
        #circle4.shift(DOWN+2*LEFT)
        #circle5 = Circle(radius=0.3, color=BLUE_B, fill_opacity=1)

        # kugel nr 4
        dest1 = Dot([-1, 1.5, 0], color=WHITE)
        dest2 = Dot([1.5, 1.5, 0], color=WHITE)
        dest3 = Dot([1.5, 0, 0], color=WHITE)
        self.add(dest1, dest2, dest3)
        dest1_loc = dest1.get_center()
        dest2_loc = dest2.get_center()
        dest3_loc = dest3.get_center()
        self.remove(dest1)
        self.remove(dest2)
        self.remove(dest3)

        self.play(dot4.animate.shift(dest1_loc - dot4.get_center()))
        self.wait(0.5)
        self.play(dot4.animate.shift(dest2_loc - dot4.get_center()))
        self.wait(0.5)
        self.play(dot4.animate.shift(dest3_loc - dot4.get_center()))
        self.wait(0.5)

        # kugel nr 1
        dest1 = Dot([-1, 1.5, 0], color=WHITE)
        dest2 = Dot([2.1, 1.5, 0], color=WHITE)
        dest3 = Dot([2.1, 0, 0], color=WHITE)
        self.add(dest1, dest2, dest3)
        dest1_loc = dest1.get_center()
        dest2_loc = dest2.get_center()
        dest3_loc = dest3.get_center()
        self.remove(dest1)
        self.remove(dest2)
        self.remove(dest3)

        self.play(dot1.animate.shift(dest1_loc - dot1.get_center()))
        self.wait(0.5)
        self.play(dot1.animate.shift(dest2_loc - dot1.get_center()))
        self.wait(0.5)
        self.play(dot1.animate.shift(dest3_loc - dot1.get_center()))
        self.wait(0.5)


        # kugel nr 3
        self.play(dot3.animate.shift([-1,1.5,0] - dot3.get_center()))
        self.wait(0.5)
        self.play(dot3.animate.shift([2.7, 1.5, 0] - dot3.get_center()))
        self.wait(0.5)
        self.play(dot3.animate.shift([2.7, 0, 0] - dot3.get_center()))
        self.wait(0.5)

        self.wait(3)
