版本比较
30秒带你搞懂小孔成像~(BV1bebSz5Eiq)
正文
增加 19 行删除 19 行
13 行未改动141516171818192021226 行未改动29303132333334353636373839394041424344454445464747484950515253545555565758596 行未改动66676869707071727374757677787980808182838418 行未改动1031041051061071071081091101111121131141151151161171171181191191201211211221231241254 行未改动13013113213313413413513613713713813914014114214314414514414514613 行未改动 def construct(self): class Light: # 光线 line: Line arrow: Arrow
def __init__(_, start, end, stroke_width, color) -> None: _.line = Line( start=xOy.c2p(start[0], start[1]), end=xOy.c2p(end[0], end[1]),6 行未改动 stroke_width=stroke_width, color=color, buff=0 )
def In(_): self.play(Create(_.line), GrowArrow(_.arrow))
def fadeout(_): self.play(FadeOut(_.line), FadeOut(_.arrow))
def In2(a: Light, b: Light): self.play(Create(a.line), GrowArrow(a.arrow), Create(b.line), GrowArrow(b.arrow)) # def Out2(a: Light, b: Light, c: Light, d: Light): # self.play(FadeOut(a.line), FadeOut(a.arrow), FadeOut(b.line), FadeOut(b.arrow), FadeOut(c.line), FadeOut(c.arrow), FadeOut(d.line), FadeOut(d.arrow))
self.wait(1)
xOy = NumberPlane( axis_config={ "stroke_color": BLUE } ) self.play(Write(xOy)) # 坐标纸 self.wait(1)
up = Line( start=xOy.c2p(0, 0.05), end=xOy.c2p(0, 4), stroke_width=10,6 行未改动 color=WHITE ) self.play(FadeIn(up), FadeIn(down)) # 小孔 self.wait(1)
obj = Arrow( start=xOy.c2p(-4, -2), end=xOy.c2p(-4, 2), stroke_width=5, color=RED, buff=0 ) self.play(FadeIn(obj)) # 物 self.wait(1)
light1 = Light( start=[-4, 2], end=[0, 0], stroke_width=3,18 行未改动 stroke_width=3, color=GRAY ) In2(light3, light4)
# pic = Arrow( # start=ORIGIN, # end=ORIGIN, # stroke_width=3, # color=GRAY, # buff=0 # )
pic = obj.copy()
self.play(FadeIn(pic))
# pics = []
for i in range(1, 8): pic.generate_target() pic.target = Arrow( start=xOy.c2p(i, i / 2),4 行未改动 ) self.play(MoveToTarget(pic)) pic = pic.target self.wait(0.5)
self.wait(2) self.play(*[FadeOut(_) for _ in self.mobjects])
self.wait(1) text = Text("谢谢观看", color=WHITE) self.play(FadeIn(text)) self.wait(2) self.play(FadeOut(text)) self.wait(1)
```