Post by Rod on Jan 26, 2023 17:21:09 GMT
Being discussed on the facebook page. First attempt here, it isn't quite right yet the waves are out of sync. Quite pleased with the filled triangle though.
'Paul Dunn challenge on facebook BASIC page
nomainwin
w=800
h=800
WindowWidth = w
WindowHeight = h
midx=int(w/2)
midy=int(h/2)
rad=57.29577951
open "Sine Thing" for graphics_nsb as #1
#1 "trapclose [quit]"
#1 "down ; fill black ; color white"
'draw static circle and frame and flush it as bac
for a=0 to 359
x=midx-50*cos(a/rad)
y=midy-50*sin(a/rad)
#1 "set ";x;" ";y
next
#1 "line 0 ";midy;" ";midx-60;" ";midy
#1 "line ";midx-60;" ";midy-50;" ";midx-60;" ";midy+50
#1 "line ";midx+60;" ";midy;" ";w;" ";midy
#1 "line ";midx+60;" ";midy-50;" ";midx+60;" ";midy+50
#1 "line ";midx;" 0 ";midx;" ";midy-60
#1 "line ";midx-50;" ";midy-60;" ";midx+50;" ";midy-60
#1 "line ";midx;" ";midy+60;" ";midx;" ";h
#1 "line ";midx-50;" ";midy+60;" ";midx+50;" ";midy+60
#1 "flush bac"
[cycle]
timer 0
'redraw the static background
#1 "redraw bac"
'get point on circle
x=midx-50*cos(a/rad)
y=midy-50*sin(a/rad)
'this is the triangle but we draw it filled later
'#1 "line ";x;" ";y;" ";midx;" ";midy
'#1 "line ";x;" ";y;" ";midx;" ";y
'#1 "line ";midx;" ";y;" ";midx;" ";midy
'the moving dotted lines
for i=0 to 10
#1 "set ";midx-50+i*10;" ";y
#1 "set ";x;" ";midy-50+i*10
next
'the sine waves (not in sync as of now!)
xr=midx+61
xl=midx-61
yd=midy+61
yu=midy-61
aa=a
for i=0 to 100
xx=midx-50*sin(aa/rad)
yy=midy-50*sin(aa/rad)
#1 "set ";xr;" ";yy
#1 "set ";xl;" ";yy
#1 "set ";xx;" ";yu
#1 "set ";xx;" ";yd
aa=aa+3
xr=xr+1
xl=xl-1
yu=yu-1
yd=yd+1
if aa>=360 then aa=aa-360
next
'draw a filled triangle using vector
'get vector norm to midx,midy to x,y
vx=midx-x
vy=midy-y
vl=sqr(vx*vx+vy*vy)
vx=vx/vl
vy=vy/vl
for i=1 to 50
x=x+vx
y=y+vy
#1 "color yellow"
#1 "line ";x;" ";y;" ";midx;" ";y
next
#1 "color white"
'move the angle
a=a+3
if a=360 then a=0
timer 16,[cycle]
wait
[quit]
timer 0
close #1
end