|
Post by tenochtitlanuk on Sept 9, 2022 17:48:12 GMT -5
One of those fun things which take rather longer than you expect! Saw on the 'net an animation that is basically like a Moire pattern- two overlapping fans rotating. Screen grab ( static) below.
My immediate thought was to generate one 'fan'... ... and then superpose a second one using Xor drawing. Then repeat at various phases. BUT I'D FORGOTTEN- LB's xor-plotting doesn't work when you drawbmp an image onto a graphic window! So I tried it making each fan blade with LINES drawn by me via the Bresenham routine previously on Forum. Result- not surprisingly when you think about it- was messy and incorrect.. Then the light dawned. Result as below. Have put the code on my websitePS You can of course CONTRArotate the two 'fans'. As above both are clockwise. PS Don't stare at this too long!!
|
|
|
Post by Rod on Sept 10, 2022 8:22:52 GMT -5
yes, a few seconds is enough, any longer and The Mad Hatter pops out the screen followed by Alice.
|
|
|
Post by tenochtitlanuk on Sept 10, 2022 11:28:06 GMT -5
Remids me of what I remember of the Sixties... perhaps the contra-rotating one will help you unwind... 
|
|
|
Post by tsh73 on Sept 10, 2022 15:38:34 GMT -5
Well, I was able to draw it with native PIEFILLED And RULE XOR (though I admit I use smaller scale)
nomainwin
WindowWidth = 350 WindowHeight = 390 open "XOR animation" for graphics_nsb_nf as #gr #gr "home; down; posxy cx cy" #gr "trapclose [quit]"
'#gr "circle 30" '#gr "go 20" #gr "color white" #gr "backcolor black" #gr "rule XOR"
pi=acs(-1) aa=0 'radians while 1 x=cx+60*cos(aa) y=cy+60*sin(aa) #gr "place ";x;" ";y for a = 0 to 350 step 15 'degrees #gr "piefilled 200 200 ";a+d;" ";7 scan next
x=cx+60*cos(aa+pi) y=cy+60*sin(aa+pi) #gr "place ";x;" ";y for a = 0 to 350 step 15 #gr "piefilled 200 200 ";a+d;" ";7 scan next
timer 50, [nxt] wait [nxt] timer 0 #gr "cls" d=(d+1) mod 15 aa=aa+1/57/5 wend
wait
[quit] timer 0 close #gr end
It got a quirk, though after I go to menu Run|Kill basic programs, I see previous runs as it does not finish properly I got it in LB 4.5.1, 4.04, JB 2.0 But in JB 1.01 it says "No programs to kill" - in that older version, program exits cleanly(?).
|
|
|
Post by tsh73 on Sept 10, 2022 15:50:30 GMT -5
Sorry cannot resist Now it is resizable nomainwin
'WindowWidth = 350 'WindowHeight = 390 WindowWidth = 500 WindowHeight = 540 'WindowWidth = 1000 'WindowHeight = 1000 open "Resize me! XOR animation" for graphics_nsb as #gr #gr "home; down; posxy cx cy" #gr "trapclose [quit]"
'#gr "circle 30" '#gr "go 20" #gr "color white" #gr "backcolor black" #gr "rule XOR"
pi=acs(-1) aa=0 'radians r=min(cx, cy)*0.35 R=int(2*min(cx, cy))/1.6 while 1 x=cx+r*cos(aa) y=cy+r*sin(aa) #gr "place ";x;" ";y for a = 0 to 350 step 15 'degrees #gr "piefilled ";R;" ";R;" ";a+d;" ";7 scan next
x=cx+r*cos(aa+pi) y=cy+r*sin(aa+pi) #gr "place ";x;" ";y for a = 0 to 350 step 15 #gr "piefilled ";R;" ";R;" ";a+d;" ";7 scan next
timer 50, [nxt] wait [nxt] timer 0 #gr "cls" d=(d+1) mod 15 aa=aa+1/57/5 #gr "home; down; posxy cx cy" r=min(cx, cy)*0.35 R=int(2*min(cx, cy))/1.6 wend
wait
[quit] timer 0 close #gr end
|
|
|
Post by Brandon Parker on Sept 11, 2022 17:23:38 GMT -5
A slightly different take on the version posted by Anatoly...
NoMainWin
WindowWidth = 650 WindowHeight = 690 Open "Resize me! XOR Animation" For graphics_nsb As #gr #gr "Home; Down; PosXY xLoc yLoc" #gr "TrapClose quit" #gr "Color White" #gr "Rule XOR" width = Int(2 * Min(xLoc, yLoc))/1.6 height = Int(2 * Min(xLoc, yLoc))/1.6 separation = Min(xLoc, yLoc) * 0.15 pi = Acs(-1) aa = 0 aa2 = aa + pi
While isWndOpen("#gr") Scan #gr "Rule XOR" #gr "BackColor Black" x1=xLoc+separation*cos(aa) y1=yLoc+separation*sin(aa) x2=xLoc+separation*cos(aa2) y2=yLoc+separation*sin(aa2) For a = 0 to 350 Step 15 'degrees #gr "Place ";x1;" ";y1 #gr "PieFilled ";width;" ";height;" ";a+d;" ";7 #gr "Place ";x2;" ";y2 #gr "PieFilled ";width;" ";height;" ";a+d;" ";7 Next a
#gr "Flush currentFrame" result = LockWindowUpdate(_NULL) #gr "Redraw currentFrame" result = Sleep(250) result = LockWindowUpdate(Hwnd(#gr))
#gr "Rule OVER" #gr "BackColor White" For a = 0 to 350 Step 15 'degrees #gr "Place ";x1;" ";y1 #gr "PieFilled ";width;" ";height;" ";a+d;" ";7 #gr "Place ";x2;" ";y2 #gr "PieFilled ";width;" ";height;" ";a+d;" ";7 Next a #gr "DelSegment currentFrame" d = (d + 1) Mod 15 aa = aa + 1/57/5 aa2 = aa + pi #gr "Home; Down; PosXY xLoc yLoc" width = Int(2 * Min(xLoc, yLoc))/1.6 height = Int(2 * Min(xLoc, yLoc))/1.6 separation = Min(xLoc, yLoc) * 0.15
Wend End
Sub quit handle$ Close #handle$ End End Sub
Function Sleep(milliseconds) CallDLL #kernel32, "Sleep", milliseconds As long, _ ret As void End Function
Function isWndOpen(handle$) On Error GoTo [Error] isWndOpen = Hwnd(#handle$) [Error] End Function
Function LockWindowUpdate(hWnd) CallDLL #user32, "LockWindowUpdate", hWnd As ulong, _ LockWindowUpdate As long End Function
{:0)
Brandon Parker
|
|