Code: Select all
graphics ! graphics clear ! draw color 0,0,0 ! draw size 1
xo=screen_width()/2 ! yo=screen_height()/2
option angle degrees
ampl=40 ! leng=780 ! angl=0 ! freq=4 ! steps=30 ! xo=0 ! refresh off
for yo=20 to 800 step 3
plot_sinus(xo,yo,angl,leng,ampl,freq,steps)
next yo
yo=0 ! angl=85
for xo=-20 to 800 step 3
plot_sinus(xo,yo,angl,leng,ampl,freq,steps)
next xo
refresh
end
' plot a sinus wave with following caracreristics
' xo and yo : starting point on the screen
' angl : angle (degrees) with wich the wave is drawn
' leng : length of the wave in # pixels
' ampl : (semi) amplitude of sine wave (pixels)
' freq : frequency of wave (# full cycles within given length)
' steps: coarseness of the graph (drawing steps per full cycle)
'
def plot_sinus(xo,yo,angl,leng,ampl,freq,steps)
dlab=leng/freq/steps
ux=cos(angl) ! uy=sin(angl) ! vx=-uy ! vy=ux
draw to xo,yo
for r=1 to leng step dlab
fac=ampl*sin(360*freq*r/leng)
x=xo+r*ux+fac*vx ! y=yo+r*uy+fac*vy
draw line to x,y
next r
end def
[attachment=0]image.jpeg[/attachment]