-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathcmd_sineplotB.py
More file actions
38 lines (30 loc) · 1.2 KB
/
Copy pathcmd_sineplotB.py
File metadata and controls
38 lines (30 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import plotext
import argparse
def main():
parser = argparse.ArgumentParser(prog="CMD-SIN",description="Sine function simulations on CMD")
parser.add_argument('-fms','--frames',type=int,default=100,help="Number of frames for the animation.")
parser.add_argument('-amp','--amplitude',type=int,default=1,help="Amplitude for sine waves.")
parser.add_argument('-per','--periods',type=int,default=4,help="Number of periods.")
parser.add_argument('-pha','--phase',type=int,default=2,help="Phase.")
args = parser.parse_args()
sine_anim(args)
def sine_anim(args):
l = 1000
x = range(1, l+1)
frames = args.frames
#plotext.title(f"Sine Animation (amp:{args.amplitude} periods:{args.periods})")
plotext.clc()
c=0
for i in range(frames):
c+=1
plotext.clt()
plotext.cld()
y = plotext.sin(args.amplitude, args.periods, l, args.phase * i / frames)
plotext.title(f"Sine Animation (amp:{args.amplitude}, periods:{args.periods}, frame:{c}/{frames})")
plotext.xlim(0, 400)
plotext.plot(x, y, marker="dot", color="red")
plotext.sleep(0.001)
plotext.show()
plotext.clear_plot()
if __name__=='__main__':
main()