' Morphing Dots ' now in Ionic Wind IWBasic 2 - March 2011 .. ' adapted for colour by GWS ' Modified April 2022 by BDP autodefine "off" $include "windowssdk.inc" INT n,cnt,object,x3d,y3d,z3d,t,q,nx,ny,speed,rc,gc,bc,run,xd FLOAT vx,sinvx,cosvx,vy,sinvy,cosvy,vz,sinvz,cosvz,tx,ty,tz,ox,c CONST numdots=30000 CONST numobjs=20 CONST distance=400 CONST ESC = 0x1B CONST scrnw = 1024 CONST scrnh = 768 CONST xhalf = scrnw/2 CONST yhalf = scrnh/2 INT points[numdots+1,4],tpoint[numdots+1,4] object=1 cnt=0 IF CREATESCREEN(scrnw,scrnh,32,&WinProc) < 0 MESSAGEBOX 0,"Unable to create DirectX screen!","Error!" END ENDIF ' turn cursor off .. ShowCursor(0) Run=1 Do cnt++ If cnt>299 ' added to change color for each object rc = rnd(255) gc = rnd(255) bc = rnd(255) object++ if object>numobjs object=1+rnd(19) endif getobjects(object) cnt=0 EndIf morphing() threed() FRONTPEN BackBuffer,RGB(0,100,255) DRAWMODE BackBuffer,@TRANSPARENT WRITETEXT 420,30, "IWBasic - Morphing Dots" WRITETEXT 440,730, "Press Esc to Exit" if object = 1 then WRITETEXT 435,400, "Generating Objects" speed = FLIP 1 if object>1 then Sleep(20) FILLSCREEN 0 Until run=0 closescreen END SUB WinProc() SELECT @MESSAGE CASE @IDCLOSEWINDOW run = 0 CASE @IDCHAR IF @CODE = ESC run = 0 ENDIF ENDSELECT RETURN 0 ENDSUB SUB threed() vx+=0.05 vy+=0.05 vz+=0.05 sinvx=sin(vx) cosvx=cos(vx) sinvy=sin(vy) cosvy=cos(vy) sinvz=sin(vz) cosvz=cos(vz) Lockbuffer For n=1 To numdots x3d=tpoint[n,1] y3d=tpoint[n,2] z3d=tpoint[n,3] ty=y3d*cosvx-z3d*sinvx tz=y3d*sinvx+z3d*cosvx tx=x3d*cosvy-tz*sinvy tz=x3d*sinvy+tz*cosvy ox=tx tx=tx*cosvz-ty*sinvz ty=ox*sinvz+ty*cosvz nx=scrnh*tx/(distance-tz)+xhalf ny=yhalf-scrnh*ty/(distance-tz) ' changed to vary colour with depth if tz>rnd(100) c = tz/30 else c = 1.0 endif WRITEPIXELFAST(nx,ny,RGB(rc*c,gc*c,bc*c)) Next n Unlockbuffer ENDSUB SUB getobjects(obj:int) Select obj Case 1 For t=1 To numdots-1 points[t,1]=(RAND(1800)-900)/10*t/numdots points[t,2]=(RAND(1800)-900)/10*t/numdots points[t,3]=(RAND(1800)-900)/10*t/numdots Next t Case 2 For t=1 To numdots xd=RAND(1800) points[t,1]=Cos(xd)*Cos(t*360/numdots)*100 points[t,2]=Cos(xd)*Sin(t*360/numdots)*100 points[t,3]=Sin(xd)*100 Next t Case 3 For t=1 To numdots xd=RAND(1800) points[t,1]=Cos(xd)*Cos(t*360/numdots)*100 points[t,2]=Cos(xd)*Sin(t*360/numdots)*100 points[t,3]=Sin(t*360/numdots)* 100 Next t Case 4 For t=1 To numdots xd=RAND(1800) points[t,1]=Sin(t*360/numdots)*Cos(t*360/numdots)*100 points[t,2]=Cos(xd)*Cos(t*360/numdots)*100 points[t,3]=Sin(t*360/numdots)*100 Next t Case 5 For t=1 To numdots xd=RAND(1800) points[t,1]=Cos(xd)*Cos(xd)*100 points[t,2]=Cos(xd)*Sin(xd)*100 points[t,3]=Sin(t*360/numdots)*100 Next t Case 6 For t=1 To numdots xd=RAND(1800) points[t,1]=Cos(xd)*Cos(xd)*100 points[t,2]=Cos(t*360/numdots)*Sin(xd)*100 points[t,3]=Sin(t*360/numdots)*100 Next t Case 7 For t=1 To numdots xd=RAND(1800) points[t,1]=Cos(t*360/numdots)*Cos(t*360/numdots)*100 points[t,2]=Cos(t*360/numdots)*Sin(xd)*100 points[t,3]=Sin(t*360/numdots)*100 Next t Case 8 For t=1 To numdots xd=RAND(1800) points[t,1]=Cos(xd)*Cos(t*360/numdots)*100 points[t,2]=Cos(xd)*Sin(t*360/numdots)*100 points[t,3]=Sin(xd)*Sin(t*360/numdots)*100 Next t Case 9 For t=1 To numdots xd=RAND(1800) points[t,1]=Sin(t*360/numdots)*Cos(t*360/numdots)*Sin(xd)*100 points[t,2]=Cos(t*360/numdots)*Sin(xd)*Cos(xd)*100 points[t,3]=Sin(xd)*Cos(t*360/numdots)*100 Next t Case 10 For t=1 To numdots xd=RAND(1800) points[t,1]=Cos(xd)*Cos(t*360/numdots)*100 points[t,2]=Cos(t*360/numdots)*Sin(xd)*100 points[t,3]=Cos(xd)*Sin(xd)*100 Next t Case 11 For t=1 To numdots xd=RAND(1800) points[t,1]=Cos(t*360/numdots)*Cos(xd)*100 points[t,2]=Cos(xd)*Sin(xd)*100 points[t,3]=Sin(xd)*100 Next t Case 12 For t=1 To numdots xd=RAND(1800) points[t,1]=Cos(xd)*Cos(t*360/numdots)*100 points[t,2]=Sin(xd)*Sin(t*360/numdots)*100 points[t,3]=Sin(xd)*100 Next t Case 13 For t=1 To numdots xd=RAND(1800) points[t,1]=Cos(t*360/numdots)*Cos(xd)*100 points[t,2]=Sin(t*360/numdots)*Sin(xd)*100 points[t,3]=Sin(t*360/numdots)*Sin(xd)*Cos(t*360/numdots)*Cos(xd)*200 Next t Case 14 For t=1 To numdots xd=RAND(1800) points[t,1]=Cos(xd)*Cos(xd)*100 points[t,2]=Sin(t*360/numdots)*Sin(xd)*100 points[t,3]=Sin(t*360/numdots)*100 Next t Case 15 For t=1 To numdots xd=RAND(1800) points[t,1]=Sin(xd)*Cos(xd)*100 points[t,2]=Sin(xd)*Sin(t*360/numdots)*100 points[t,3]=Sin(t*360/numdots)*100 Next t Case 16 For t=1 To numdots xd=RAND(1800) points[t,1]=Cos(xd)*Cos(t*360/numdots)*100 points[t,2]=Cos(t*360/numdots)*Sin(t*360/numdots)*100 points[t,3]=Sin(xd)*Cos(t*360/numdots)*100 Next t Case 17 For t=1 To numdots xd=RAND(1800) points[t,1]=Cos(xd)*Cos(t*360/numdots)*Sin(t*360/numdots)*100 points[t,2]=Sin(t*360/numdots)*Sin(xd)*Cos(t*360/numdots)*100 points[t,3]=Sin(xd)*Cos(t*360/numdots)*100 Next t Case 18 For t=1 To numdots xd=RAND(1800) points[t,1]=Cos(xd)*Cos(xd)*100 points[t,2]=Cos(t*360/numdots)*Sin(t*360/numdots)*100 points[t,3]=Sin(t*360/numdots)*100 Next t Case 19 For t=1 To numdots xd=RAND(1800) points[t,1]=Cos(xd)*Sin(t*360/numdots)*100 points[t,2]=Cos(xd)*Cos(t*360/numdots)*100 points[t,3]=Cos(xd)*100 Next t Case 20 For t=1 To numdots xd=RAND(1800) points[t,1]=Sin(xd)*Cos(xd)*Sin(t*360/numdots)*200 points[t,2]=Sin(t*360/numdots)*Cos(t*360/numdots)*Sin(xd)*200 points[t,3]=Sin(t*360/numdots)*Cos(xd)*Cos(t*360/numdots)*200 Next t EndSelect ENDSUB SUB morphing() For t=1 To numdots For q=1 To 3 If points[t,q]>tpoint[t,q] tpoint[t,q]=tpoint[t,q]+1 Endif IF points[t,q]