|
Post by Rod on Apr 16, 2022 11:06:57 GMT -5
This is a conversion of Spec BASIC code posted on Carl's BASIC facebook page. Nice.
nomainwin WindowWidth =800 WindowHeight =600 UpperLeftX = int((DisplayWidth-WindowWidth)/2) UpperLeftY = int((DisplayHeight-WindowHeight)/2) open "Sins" for graphics_nsb as #1 #1 "down ; fill black ; trapclose [quit]"
pi = acs(-1)
for a=0 to 7 for b=0 TO 7 #1 "color ";(a+b)/2*51;" 128 192" for i=0 to 2*pi step .004 #1 "set ";x(a,b,i);" ";y(a,b,i) next i next b next a #1 "getbmp bac 0 0 800 600 ; backcolor white"
[loop] #1 "discard ; drawbmp bac 0 0" for a=0 to 7 for b=0 TO 7 #1 "place ";x(a,b,i);" ";y(a,b,i);" ; circlefilled 3" next b next a i=i+.02 scan goto [loop]
[quit] close #1 end
function x(a,b,i) x=190+60*a+28*SIN ((a+1)*i) end function
function y(a,b,i) y=30+60*b-28*COS ((b+1)*i) end function
|
|
|
Post by Carl Gundel on Apr 16, 2022 11:59:13 GMT -5
This is a conversion of Spec BASIC code posted on Carl's BASIC facebook page. Nice. That's fun. 
|
|
|
Post by tenochtitlanuk on Apr 16, 2022 14:36:06 GMT -5
Neat demo. And to think that 60+ years ago we had to make Lissajous figures with a sand pendulum!  And the excitement of building a cathode ray oscilloscope with Army-surplus 3.5 inch screen and old TV valves in about 1967. x/t, but also x/y so could show Lissajous figures once I'd built a sine wave generator- but I had to photograph the screen and develop/print for permanent records. Rapidly learned to treat UK mains 240V with respect... happy days!
|
|
|
Post by tsh73 on Apr 16, 2022 16:39:19 GMT -5
Just made EXE and send it along. Using of background just brilliant.
|
|
dkl
Full Member
 
Posts: 234
|
Post by dkl on Apr 16, 2022 17:44:24 GMT -5
Brilliant .....Love It! 
|
|
|
Post by Rod on Apr 17, 2022 9:20:31 GMT -5
I tried a proper hsv2rgb function. I used tsh73's code. The initial drawing was slow because there was too much detail.
nomainwin WindowWidth =800 WindowHeight =600 UpperLeftX = int((DisplayWidth-WindowWidth)/2) UpperLeftY = int((DisplayHeight-WindowHeight)/2) open "Sins" for graphics_nsb as #1 #1 "down ; fill black ; trapclose [quit]"
pi = acs(-1)
for a=0 to 7 for b=0 TO 7 #1 "color ";hsvtorgb$((a+b)/2*51,1,1) for i=0 to 2*pi step .04 #1 "set ";x(a,b,i);" ";y(a,b,i) next i next b next a #1 "getbmp bac 0 0 800 600 ; backcolor white"
[loop] #1 "discard ; drawbmp bac 0 0" for a=0 to 7 for b=0 TO 7 #1 "place ";x(a,b,i);" ";y(a,b,i);" ; circlefilled 3" next b next a i=i+.02 scan goto [loop]
[quit] close #1 end
function hsvtorgb$(h,s,v) 'tsh73 'Input: (h,s,v) 'h in the range [0, 360), indicating the angle, in degrees of the hue 's and v varying between 0 and 1, representing the saturation and value, respectively 'Output: r,g,b [0,1] 'and to be useful, R G B [0 255] 'or to JB RGB$ as "R G B" string.
hi = int(h/60) mod 6 f = h/60 - int(h/60) p = v*(1-s) q= v*(1-f*s) t = v*(1-(1-f)*s) select case hi case 0 r = v: g = t: b = p case 1 r = q: g = v: b = p case 2 r = p: g = v: b = t case 3 r = p: g = q: b = v case 4 r = t: g = p: b = v case 5 r = v: g = p: b = q end select R = int(r*255) G = int(g*255) B = int(b*255) hsvtorgb$ = R;" ";G;" ";B end function
function x(a,b,i) x=190+60*a+28*SIN ((a+1)*i) end function
function y(a,b,i) y=30+60*b-28*COS ((b+1)*i) end function
|
|