from manim import *
import numpy as np
from numpy import array, pi, cos, sin
run_time = 1
data = [[1, 2], [3, 4]]

def dot(pos, **kwargs):
    return Dot(pos, **kwargs)
class N155_04(Scene):
    def construct(self):
        sc = self
        def interpolate_mobject(self, alpha):
            """插值函数，控制彩色气泡的动画效果"""
            dt = 1 / config.frame_rate
            for bubble in self.bubbles:
                bubble.shift(UP * bubble.rise_speed * dt)
                bubble.scale(1 + bubble.growth_rate * dt)
                current_opacity = bubble.get_fill_opacity()
                new_opacity = current_opacity - bubble.fade_rate * dt
                if new_opacity <= 0 or bubble.get_y() > config.frame_height / 2:
                    x_pos = random.uniform(-config.frame_width / 2 + 1, config.frame_width / 2 - 1)
                    y_pos = random.uniform(-config.frame_height / 2, -config.frame_height / 2 + 2)
                    bubble.move_to([x_pos, y_pos, 0])
                    bubble.set_fill(opacity=0.4)
                    bubble.set_stroke(opacity=0.4)
                else:
                    bubble.set_fill(opacity=new_opacity)
                    bubble.set_stroke(opacity=new_opacity)
        self.wait(0.5)
