| 4 | |
| 5 | |
| 6 | class PlotGraph(Scene): |
| 7 | def construct(self): |
| 8 | render = True |
| 9 | dt = 1 / 15 |
| 10 | caption_size = 30 |
| 11 | |
| 12 | # Create title "Model-Free Diffusion" |
| 13 | title = Text("Standard Model-Free Diffusion", font_size=40).shift(UP * 3) |
| 14 | |
| 15 | # Create two box side by side |
| 16 | box1 = Rectangle(width=4, height=4).shift(LEFT * 3) |
| 17 | box2 = Rectangle(width=4, height=4).shift(RIGHT * 3) |
| 18 | |
| 19 | # Create circle in the center of each box filled with blue |
| 20 | r = 0.5 |
| 21 | circle1 = Circle(radius=r, color=BLUE, fill_opacity=1).shift(box1.get_center()) |
| 22 | circle2 = Circle(radius=r, color=BLUE, fill_opacity=1).shift(box2.get_center()) |
| 23 | |
| 24 | # Create curve from [0, -1.5] to [0, 1.5] passing [-0.5, 0] |
| 25 | demo_curves = [] |
| 26 | for _ in range(4): |
| 27 | x = np.random.uniform(0.5, 0.8) |
| 28 | curve = ParametricFunction( |
| 29 | lambda t: np.array([x * np.cos(t / 3.0 * np.pi), t, 0]), |
| 30 | t_range=[-1.5, 1.5], |
| 31 | color=RED, |
| 32 | ).shift(box1.get_center()) |
| 33 | demo_curves.append(curve) |
| 34 | for _ in range(4): |
| 35 | x = np.random.uniform(0.5, 0.8) |
| 36 | curve = ParametricFunction( |
| 37 | lambda t: np.array([-x * np.cos(t / 3.0 * np.pi), t, 0]), |
| 38 | t_range=[-1.5, 1.5], |
| 39 | color=RED, |
| 40 | ).shift(box1.get_center()) |
| 41 | demo_curves.append(curve) |
| 42 | |
| 43 | # Create vector field in the box2 |
| 44 | def demo_vector_field_fn(x): |
| 45 | value = (x[0] / 0.6) ** 2 + (x[1] / 1.5) ** 2 - 1.0 |
| 46 | vec = 0.2 * np.array([x[0] / 0.6, x[1] / 1.5]) |
| 47 | if value < 0: |
| 48 | return vec |
| 49 | else: |
| 50 | return -vec |
| 51 | |
| 52 | demo_vector_field = ArrowVectorField( |
| 53 | demo_vector_field_fn, |
| 54 | x_range=[-2, 2], |
| 55 | y_range=[-2, 2], |
| 56 | length_func=lambda norm: np.clip(norm, 0, 0.5), |
| 57 | color=RED, |
| 58 | ).shift(box2.get_center()) |
| 59 | |
| 60 | demo_title = Text("Demonstrations", font_size=30).shift( |
| 61 | box1.get_top() + UP * 0.5 |
| 62 | ) |
| 63 | diffusion_title = Text("Diffusion Process", font_size=30).shift( |
nothing calls this directly
no outgoing calls
no test coverage detected