def setup_in_uv_space(self):
     u_values, v_values = self.get_u_values_and_v_values()
     faces = VGroup()
     for i in range(len(u_values) - 1):
         for j in range(len(v_values) - 1):
             u1, u2 = u_values[i:i + 2]
             v1, v2 = v_values[j:j + 2]
             face = ThreeDVMobject()
             face.set_points_as_corners([
                 [u1, v1, 0],
                 [u2, v1, 0],
                 [u2, v2, 0],
                 [u1, v2, 0],
                 [u1, v1, 0],
             ])
             faces.add(face)
             face.u_index = i
             face.v_index = j
             face.u1 = u1
             face.u2 = u2
             face.v1 = v1
             face.v2 = v2
     faces.set_fill(
         color=self.fill_color,
         opacity=self.fill_opacity
     )
     faces.set_stroke(
         color=self.stroke_color,
         width=self.stroke_width,
         opacity=self.stroke_opacity,
     )
     self.add(*faces)
     if self.checkerboard_colors:
         self.set_fill_by_checkerboard(*self.checkerboard_colors)
Example #2
0
 def setup_in_uv_space(self):
     u_values, v_values = self.get_u_values_and_v_values()
     faces = VGroup()
     for i in range(len(u_values) - 1):
         for j in range(len(v_values) - 1):
             u1, u2 = u_values[i:i + 2]
             v1, v2 = v_values[j:j + 2]
             face = ThreeDVMobject()
             face.set_points_as_corners([
                 [u1, v1, 0],
                 [u2, v1, 0],
                 [u2, v2, 0],
                 [u1, v2, 0],
                 [u1, v1, 0],
             ])
             faces.add(face)
             face.u_index = i
             face.v_index = j
             face.u1 = u1
             face.u2 = u2
             face.v1 = v1
             face.v2 = v2
     faces.set_fill(
         color=self.fill_color,
         opacity=self.fill_opacity
     )
     faces.set_stroke(
         color=self.stroke_color,
         width=self.stroke_width,
         opacity=self.stroke_opacity,
     )
     self.add(*faces)
     if self.checkerboard_colors:
         self.set_fill_by_checkerboard(*self.checkerboard_colors)
Example #3
0
    def __init__(self, point, color=YELLOW, **kwargs):
        digest_config(self, kwargs)
        lines = VGroup()
        for angle in np.arange(0, TAU, TAU / self.num_lines):
            line = Line(ORIGIN, self.line_length * RIGHT)
            line.shift((self.flash_radius - self.line_length) * RIGHT)
            line.rotate(angle, about_point=ORIGIN)
            lines.add(line)
        lines.move_to(point)
        lines.set_color(color)
        lines.set_stroke(width=3)
        line_anims = [
            ShowCreationThenDestruction(
                line, rate_func=squish_rate_func(smooth, 0, 0.5)
            )
            for line in lines
        ]
        fade_anims = [
            UpdateFromAlphaFunc(
                line, lambda m, a: m.set_stroke(
                    width=self.line_stroke_width * (1 - a)
                ),
                rate_func=squish_rate_func(smooth, 0, 0.75)
            )
            for line in lines
        ]

        AnimationGroup.__init__(
            self, *line_anims + fade_anims, **kwargs
        )
 def create_lines(self):
     lines = VGroup()
     for angle in np.arange(0, TAU, TAU / self.num_lines):
         line = Line(ORIGIN, self.line_length * RIGHT)
         line.shift((self.flash_radius - self.line_length) * RIGHT)
         line.rotate(angle, about_point=ORIGIN)
         lines.add(line)
     lines.set_stroke(color=self.color, width=self.line_stroke_width)
     lines.add_updater(lambda l: l.move_to(self.point))
     return lines
Example #5
0
 def get_color_palette(self):
     palette = VGroup(
         *(Square(fill_color=color, fill_opacity=1, side_length=1)
           for color in self.palette_colors))
     palette.set_stroke(width=0)
     palette.arrange(RIGHT, buff=0.5)
     palette.set_width(FRAME_WIDTH - 0.5)
     palette.to_edge(DOWN, buff=SMALL_BUFF)
     palette.fix_in_frame()
     return palette