def construct(self): ShowRearrangementInBigSquare.construct(self) self.highlight_region(region_from_polygon_vertices( 2*(LEFT+UP), 2*LEFT+DOWN, RIGHT+DOWN, RIGHT+2*UP ), color = B_COLOR) self.highlight_region(region_from_polygon_vertices( RIGHT+DOWN, RIGHT+2*DOWN, 2*RIGHT+2*DOWN, 2*RIGHT+DOWN ), color = A_COLOR)
def construct(self): ShowRearrangementInBigSquare.construct(self) self.set_color_region(region_from_polygon_vertices( 2*(LEFT+UP), 2*LEFT+DOWN, RIGHT+DOWN, RIGHT+2*UP ), color = B_COLOR) self.set_color_region(region_from_polygon_vertices( RIGHT+DOWN, RIGHT+2*DOWN, 2*RIGHT+2*DOWN, 2*RIGHT+DOWN ), color = A_COLOR)
def construct(self, num, fill): DrawAllThreeSquares.construct(self) pairs = [ ((0, 2, 0), (1, -1, 0)), ((-3, -1, 0), (0, -2, 0)), ((4, -1, 0), (1, -2, 0)), ((0, -2, 0), (-3, -1, 0)), ((1, -2, 0), (4, -1, 0)), ((1, -1, 0), (4, 0, 0)), ((4, 0, 0), (3, 3, 0)), ((3, 3, 0), (0, 2, 0)), ((-3, 3, 0), (0, 2, 0)), ((0, 2, 0), (-3, 3, 0)) ] to_flip = [1, 3, 8, 9] for n in range(num): triangle = Triangle() if n in to_flip: triangle.rotate(np.pi, UP) self.add(triangle.place_hypotenuse_on(*pairs[n])) vertices = list(triangle.get_vertices()) if n not in to_flip: vertices.reverse() if fill: self.set_color_region( region_from_polygon_vertices(*vertices), color = DARK_BLUE )
def construct(self, num, fill): DrawAllThreeSquares.construct(self) pairs = [ ((0, 2, 0), (1, -1, 0)), ((-3, -1, 0), (0, -2, 0)), ((4, -1, 0), (1, -2, 0)), ((0, -2, 0), (-3, -1, 0)), ((1, -2, 0), (4, -1, 0)), ((1, -1, 0), (4, 0, 0)), ((4, 0, 0), (3, 3, 0)), ((3, 3, 0), (0, 2, 0)), ((-3, 3, 0), (0, 2, 0)), ((0, 2, 0), (-3, 3, 0)) ] to_flip = [1, 3, 8, 9] for n in range(num): triangle = Triangle() if n in to_flip: triangle.rotate(np.pi, UP) self.add(triangle.place_hypotenuse_on(*pairs[n])) vertices = list(triangle.get_vertices()) if n not in to_flip: vertices.reverse() if fill: self.highlight_region( region_from_polygon_vertices(*vertices), color = DARK_BLUE )
def construct(self, *args): DrawAllThreeSquaresWithMoreTriangles.construct(self, *args) args_list = [(10, False)] color = Color("yellow") color.set_rgb(0.3 * np.array(color.get_rgb())) self.highlight_region(region_from_polygon_vertices((-3, 3), (-3, -2), (4, -2), (4, 3)), color=color)
def set_color_triangles(self): for mob in self.mobjects: if isinstance(mob, Triangle): vertices = list(mob.get_vertices()) for x in range(2): self.set_color_region( region_from_polygon_vertices(*vertices), color=BLUE_D) vertices.reverse() #silly hack
def highlight_triangles(self): for mob in self.mobjects: if isinstance(mob, Triangle): vertices = list(mob.get_vertices()) for x in range(2): self.highlight_region( region_from_polygon_vertices(*vertices), color=DARK_BLUE) vertices.reverse() #silly hack
def highlight_triangles(self): for mob in self.mobjects: if isinstance(mob, Triangle): vertices = list(mob.get_vertices()) for x in range(2): self.highlight_region(region_from_polygon_vertices( *vertices ), color = DARK_BLUE) vertices.reverse()#silly hack
def construct(self, *args): AddParallelLines.construct(self, *args) triplets = [ [(0, 2), (0, -1), (1, -1)], [(1, -1), (4, -1), (4, 0)], [(4, 0), (4, 3), (3, 3)], [(3, 3), (0, 3), (0, 2)], ] for triplet in triplets: self.highlight_region(region_from_polygon_vertices(*triplet), color="DARK_BLUE")
def construct(self, *args): AddParallelLines.construct(self, *args) triplets = [ [(0, 2), (0, -1), (1, -1)], [(1, -1), (4, -1), (4, 0)], [(4, 0), (4, 3), (3, 3)], [(3, 3), (0, 3), (0, 2)], ] for triplet in triplets: self.highlight_region( region_from_polygon_vertices(*triplet), color = "DARK_BLUE" )
def construct(self, *args): DrawAllThreeSquaresWithMoreTriangles.construct(self, *args) args_list = [(10, False)] color = Color("yellow") color.set_rgb(0.3*np.array(color.get_rgb())) self.highlight_region( region_from_polygon_vertices( (-3, 3), (-3, -2), (4, -2), (4, 3) ), color = color )
def construct(self): big_grid_dim = 20. small_grid_dim = 6. big_grid = Grid(64, 64, height=big_grid_dim, width=big_grid_dim) big_grid.to_corner(UP + RIGHT, buff=2) small_grid = big_grid.copy() small_grid.scale(small_grid_dim / big_grid_dim) small_grid.center() pixel = MobjectFromRegion( region_from_polygon_vertices( *0.2 * np.array([RIGHT + DOWN, RIGHT + UP, LEFT + UP, LEFT + DOWN]))) pixel.set_color(WHITE) pixel_width = big_grid.width / big_grid.columns pixel.scale_to_fit_width(pixel_width) pixel.to_corner(UP + RIGHT, buff=2) pixel.shift(5 * pixel_width * (2 * LEFT + DOWN)) freq_line = get_freq_line() dot = Dot() dot.shift(freq_line.get_center() + 2 * RIGHT) string = Line(LEFT, RIGHT, color=GREEN) arrow = Arrow(dot, string.get_center()) vibration_config = { "overtones": 1, "spatial_period": 2, } vibration, loud_vibration, quiet_vibration = [ Vibrate(string.copy(), amplitude=a, **vibration_config) for a in [0.5, 1., 0.25] ] self.add(small_grid) self.wait() self.play(Transform(small_grid, big_grid)) self.play(FadeIn(pixel)) self.wait() self.play(FadeOut(small_grid), ShowCreation(freq_line)) self.remove(small_grid) self.play(Transform(pixel, dot), ) self.wait() self.play(ShowCreation(arrow)) self.play(loud_vibration) self.play(TransformAnimations(loud_vibration, quiet_vibration), ApplyMethod(dot.fade, 0.9)) self.clear() self.add(freq_line, dot, arrow) self.play(quiet_vibration)
def construct(self, *args): DrawCSquareWithAllTraingles.construct(self, *args) self.set_color_region(region_from_polygon_vertices( *c_square().center().get_vertices() ), color = YELLOW)
def construct(self): big_grid_dim = 20. small_grid_dim = 6. big_grid = Grid(64, 64, height = big_grid_dim, width = big_grid_dim) big_grid.to_corner(UP+RIGHT, buff = 2) small_grid = big_grid.copy() small_grid.scale(small_grid_dim/big_grid_dim) small_grid.center() pixel = MobjectFromRegion( region_from_polygon_vertices(*0.2*np.array([ RIGHT+DOWN, RIGHT+UP, LEFT+UP, LEFT+DOWN ])) ) pixel.set_color(WHITE) pixel_width = big_grid.width/big_grid.columns pixel.scale_to_fit_width(pixel_width) pixel.to_corner(UP+RIGHT, buff = 2) pixel.shift(5*pixel_width*(2*LEFT+DOWN)) freq_line = get_freq_line() dot = Dot() dot.shift(freq_line.get_center() + 2*RIGHT) string = Line(LEFT, RIGHT, color = GREEN) arrow = Arrow(dot, string.get_center()) vibration_config = { "overtones" : 1, "spatial_period" : 2, } vibration, loud_vibration, quiet_vibration = [ Vibrate(string.copy(), amplitude = a, **vibration_config) for a in [0.5, 1., 0.25] ] self.add(small_grid) self.dither() self.play( Transform(small_grid, big_grid) ) self.play(FadeIn(pixel)) self.dither() self.play( FadeOut(small_grid), ShowCreation(freq_line) ) self.remove(small_grid) self.play( Transform(pixel, dot), ) self.dither() self.play(ShowCreation(arrow)) self.play(loud_vibration) self.play( TransformAnimations(loud_vibration, quiet_vibration), ApplyMethod(dot.fade, 0.9) ) self.clear() self.add(freq_line, dot, arrow) self.play(quiet_vibration)
def construct(self, *args): DrawCSquareWithAllTraingles.construct(self, *args) self.highlight_region(region_from_polygon_vertices( *c_square().center().get_vertices() ), color = YELLOW)