Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SelectionScene(Scene):
- def construct(self):
- text = VGroup(
- TextMobject("Lorem ipsum dolor sit amet,"),
- TextMobject("consectetur adipiscing elit,"),
- TextMobject("sed do eiusmod tempor incididunt"),
- TextMobject("ut labore et dolore magna aliqua.")
- )
- text.arrange(DOWN,aligned_edge=LEFT)
- text_it = iter([*text])
- rect = self.selection_rectangle(next(text_it))
- self.play(FadeIn(text))
- self.play(GrowFromEdge(rect,LEFT))
- for _ in range(len(text)-1):
- self.play(ApplyFunction(
- lambda mob: mob.set_y(next(text_it).get_y()),
- rect
- )
- )
- self.wait()
- def selection_rectangle(self,text,buff=1,**kwargs):
- Rectangle.CONFIG["color"] = YELLOW
- Rectangle.CONFIG["stroke_opacity"] = 0
- Rectangle.CONFIG["fill_opacity"] = 0.4
- rect = Rectangle(
- width=FRAME_WIDTH-2*buff,
- height=text.get_height(),
- **kwargs
- )
- rect.move_to(ORIGIN)
- rect.set_y(text.get_y())
- return rect
- class Patronhexagon(Scene):
- CONFIG={
- "color_hexagon":BLUE_C,
- }
- def construct(self):
- hexagon1 = self.get_hexagons()
- hexagon2 = self.get_hexagons()
- hexagon3 = self.get_hexagons()
- hexagon4 = self.get_hexagons()
- VGroup(hexagon1,hexagon2).arrange(RIGHT).move_to(ORIGIN)
- VGroup(hexagon3,hexagon4).arrange(DOWN).move_to(ORIGIN)
- hexagon3.shift(UP)
- hexagon4.shift(DOWN)
- h1 = VGroup(hexagon1,hexagon2,hexagon3,hexagon4).set_stroke(opacity=0.5)
- h2 = h1.copy().set_stroke(opacity=0.5)
- VGroup(h1,h2).arrange(RIGHT)
- titulo=TextMobject("LaggedStart animation",color=WHITE,background_stroke_width=2).scale(2.5)
- self.play(
- *[LaggedStartMap(ShowCreationThenDestruction,
- h,
- run_time=4.5,
- lag_ratio=0.1,
- rate_func=lambda t:smooth(t*1.3,inflection=11))for h in h1],
- *[LaggedStartMap(ShowCreationThenDestruction,
- h,
- run_time=4.5,
- lag_ratio=0.1,
- rate_func=lambda t:smooth(t*1.3,inflection=11))for h in h2],
- Write(titulo,run_time=7,rate_func=lambda t:there_and_back(1.1*t))
- )
- def get_hexagons(self,partitions=6,rot=PI/2,stroke_init=1,stroke_end=25):
- hexagon = VGroup()
- for part in range(1,partitions+1):
- hexag = RegularPolygon(n=6,color=self.color_hexagon)\
- .scale(part/partitions).rotate(rot)
- stroke_gradient = (stroke_init - stroke_end) / part
- hexag.set_stroke(None,stroke_init-stroke_gradient)
- hexag.move_to(ORIGIN)
- hexagon.add(hexag)
- hexagon.scale(2)
- return hexagon
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement