12345678910111213141516171819202122232425262728293031323334 |
- #!/usr/bin/env python3
- from PIL import Image
- from math import sin, pi
- def main():
- inter = Image.open('../figures/interferometer_schematic.png')
- size_x, size_y = inter.size
- n = 50
- def combine(t):
- A = 20
- w = 2*2*pi/n
- offset = int(A*sin(w*t))
- bg = Image.new('RGBA', (1000, 1000), color=(255, 255, 255, 0))
- inter2 = inter.resize((size_x-offset, size_y+offset))
- bg.paste(inter2, box=(50+offset//2, 50-offset//2))
- # bg.show()
- return bg
- frames = [combine(i) for i in range(n)]
- frames[0].save('stretch_squeeze.gif', save_all=True, append_images=frames[1:], duration=int(1000/30), loop=0)
- frames[0].save('stretch_squeeze_start.gif')
- if __name__ == '__main__':
- main()
|