|
Post by Rod on Aug 31, 2022 11:05:12 GMT
|
|
|
Post by plus on Aug 31, 2022 16:31:25 GMT
This code produces 2 different plots, if you could convert them to sprites it might not blink so badly and the 2 shots would produce illusion of movement.
Otherwise JB can't draw these nearly fast enough!
nomainwin
'open a window and graphicbox WindowHeight = 350 WindowWidth = 600 'graphicbox #w.g, 0, 0, 400, 300 open "sprite test" for graphics_nsb_nf as #w #w "trapclose [quit]" #w "color red" #w "down"
M = 313 P = 100 J = 1 while 1 #w "fill white" scan FOR I = 0 TO 1.567 STEP .00050 J=0-J #w "set ";ABS(P*(J*I+3));" ";P*(2+(I^.01*( ABS(COS(I))^.5*COS (M*I))-I^.3)) NEXT wend wait
[quit] close #w end
|
|
|
Post by tenochtitlanuk on Aug 31, 2022 20:07:20 GMT
Save the two screens as bmps. In LB, programmatically, or in JB manually, convert the two to animated gif. In LB call your web browser to show the gif.In JB do it manually. In true Brit fashion, I decided to be a true blue-blooded aristocrat. PS Care to modify it to at least three stages rather than two??
|
|
|
Post by plus on Sept 1, 2022 2:48:57 GMT
Yeah for some reason I couldn't get this to work this morning, 2nd try tonight and success!
Here is code
nomainwin Global XMAX, YMAX XMAX = 600 YMAX = 350 WindowWidth = XMAX + 8 WindowHeight = YMAX + 32 UpperLeftX = (1200 - XMAX) / 2 UpperLeftY = (700 - YMAX) / 2 open "sprite test" for graphics_nsb_nf as #w #w "trapclose quit" #w "color red" #w "down" #w "size 2" M = 313 P = 100 J = 1 FOR I = 0 TO 1.567 STEP .0005 J=0-J #w "set ";ABS(P*(J*I+3));" ";P*(2+(I^.01*( ABS(COS(I))^.5*COS (M*I))-I^.3)) NEXT #w "getbmp hart 0 0 ";XMAX;" ";YMAX
#w "fill white" scan FOR I = 0 TO 1.567 STEP .00050 J=0-J #w "set ";ABS(P*(J*I+3));" ";P*(2+(I^.01*( ABS(COS(I))^.5*COS (M*I))-I^.3)) NEXT #w "getbmp heart 0 0 ";XMAX;" ";YMAX while 1 scan toggle = 1 - toggle if toggle then #w "background hart" else #w "background heart" end if #w "drawsprites" scan call pause 200 wend wait
sub quit H$ close #w end end sub
sub pause mil 'tsh version has scan built-in t0 = time$("ms") while time$("ms") < t0 + mil : scan : wend end sub
Good luck getting another stage john ;-))
|
|
|
Post by Rod on Sept 1, 2022 7:47:34 GMT
I am not understanding how the drawing differs, we use exactly the same drawing code. What is it that nudges the drawing and causes the apparent rotation?
|
|
|
Post by tsh73 on Sept 1, 2022 10:28:16 GMT
That's the brain tricks. Two frames are interpolated to rotation. How have a look at this... I wonder how it behaves on faster machine. On mine it shows 2 FPS Also why it sometimes moves very slow while sometimes jumps.
nomainwin
WindowHeight = 350 WindowWidth = 600
open "sprite test" for graphics_nsb_nf as #w #w "trapclose [quit]" #w "color red" #w "down" #w "size 2" M = 313 P = 100 J = 1 t0=time$("ms") while 1
scan t = time$("ms")-t0 k=k+1 'print k, .5/(P*5+k/60)
FOR I = 0 TO 1.567 STEP .5/(P*5+k/60) J=0-J
'instead of FILL WHITE #w "color white" x=int(ABS(P*(J*I+3))) if x<>x1 and x<>x2 then 'if changed #w "line ";x+J;" 0 ";x+J;" 350"; x2=x1:x1=x end if
'the point #w "color red" #w "set ";x;" ";int(P*(2+(I^.01*( ABS(COS(I))^.5*COS (M*I+k/60))-I^.3)))
NEXT
#w "discard" 'FPS iter=iter+1 if t1$<>time$("sec") then t1$=time$("sec") FPS=iter iter=0 end if
#w "place 10 30; backcolor blue" #w "\FPS ";FPS;" " wend wait [quit] close #w end
sub pause mil 'SCAN and QUIT t0 = time$("ms") while time$("ms") < t0 + mil : scan : wend exit sub [quit] close #w end end sub
|
|
|
Post by Rod on Sept 1, 2022 10:57:26 GMT
Thanks, I get 8fps. The animation starts in a quite structured way but over time descends in to more chaotic drawing. it seems to have half a cycle of structured y rotation then less structured x rotation. Bizarre Lissajous!
|
|
|
Post by tsh73 on Sept 1, 2022 11:13:48 GMT
really, in
ABS(COS(I))^.5*COS (M*I+k/60))-I^.3
COS (M*I+k/60)) is Lissajous part and
ABS(COS(I))^.5-I^.3 is heart-shaped part (lower one) (and without -I^.3 I got Lissajous-in-the-oval) So we probably could modify Lissajous only, to get nice rotation effect.
|
|
|
Post by plus on Sept 1, 2022 12:22:00 GMT
I am not understanding how the drawing differs, we use exactly the same drawing code. What is it that nudges the drawing and causes the apparent rotation? I did change the step from .00055 to .0005 to get two phases as J is flipped with -J between the two phases. I was surprised later with a slow mo that it draws all those dots from center out. I is like X but with way more than one Y value. Gotta see what tsh73 did
|
|
|
Post by marshawn on Sept 1, 2022 12:36:02 GMT
nice mods B+ and others -- this thread is very JBesque
|
|
|
Post by plus on Sept 1, 2022 15:46:47 GMT
nomainwin Global XMAX, YMAX XMAX = 600 YMAX = 350 WindowWidth = XMAX + 8 WindowHeight = YMAX + 32 UpperLeftX = (1200 - XMAX) / 2 UpperLeftY = (700 - YMAX) / 2 open "Heart Beat" for graphics_nsb_nf as #w #w "trapclose quit" #w "color red" #w "down" #w "size 2" M = 313 P = 100 J = 1 for stepper = .0005 to .0005004 step .0000001 k = k+1 #w "fill white" FOR I = 0 TO 1.567 STEP stepper J=0-J #w "set ";ABS(P*(J*I+3));" ";P*(2+(I^.01*( ABS(COS(I))^.5*COS (M*I))-I^.3)) NEXT #w "getbmp hart";k;" 0 0 ";XMAX;" ";YMAX next k = 0 : dk = 1 while 1 scan k = k + dk if k > 4 then k = 1 #w "background hart";k #w "drawsprites" scan toggle = 1 - toggle if toggle then call pause 800 else call pause 80 wend wait
sub quit H$ close #w end end sub
sub pause mil 'tsh version has scan built-in t0 = time$("ms") while time$("ms") < t0 + mil : scan : wend end sub
www.youtube.com/watch?v=xos2MnVxe-c
|
|
|
Post by tsh73 on Sept 3, 2022 7:47:16 GMT
Reusing some of B+ code - got smooth rotation! (10 frames)
EDIT "+k/30" is difference between frames (trial and error) "50" in "pause 50" is time between frames
nomainwin
WindowHeight = 350 WindowWidth = 600
open "sprite test" for graphics_nsb_nf as #w #w "trapclose [quit]" #w "color red" #w "down" #w "home; posxy cx cy" XMAX=2*cx: YMAX=2*cy
#w "size 2" M = 313 P = 100 J = 1
for k = 0 to 9 I=0 J=0 x=int(ABS(P*(J*I+3))) #w "color white" #w "line ";x+J;" 0 ";x+J;" 350";
J=1 FOR I = 0 TO 1.567 STEP 0.0005'.5/(P*5+k/60) scan J=0-J
'instead of FILL WHITE #w "color white" x=int(ABS(P*(J*I+3))) if x<>x1 and x<>x2 then 'if changed #w "line ";x+J;" 0 ";x+J;" 350"; x2=x1:x1=x end if
'the point #w "color red" #w "set ";x;" ";int(P*(2+(I^.01*( ABS(COS(I))^.5*COS (M*I+k/30))-I^.3))) '#w "set ";x;" ";int(P*(2+(I^.01*( COS (M*I+k/60)))))
NEXT #w "getbmp hart";k;" 0 0 ";XMAX;" ";YMAX
#w "discard" next
k = 0 : dk = 1 while 1 scan k = k + dk if k > 9 then k = 0 #w "background hart";k #w "drawsprites" scan 'toggle = 1 - toggle 'if toggle then call pause 800 else call pause 80 call pause 50 wend wait
wait [quit] close #w end
sub pause mil 'SCAN and QUIT t0 = time$("ms") while time$("ms") < t0 + mil : scan : wend exit sub [quit] close #w end end sub
|
|
|
Post by Rod on Sept 3, 2022 7:56:33 GMT
Excellent, very nice animation.
|
|
|
Post by plus on Sept 3, 2022 13:12:14 GMT
Nice tsh73, you got a smooth transition for 10 frames!
|
|