From my fertile imagination... ' "Spoim", an FB^3 program for Standard Runtime. ' Simulates a certain something under a microscope. :) ' Wu Pixels based on pseudocode by Hugo Elias ' < http://freespace.virgin.net/hugo.elias > ' FB Animated Wu Pixels by Robert Covington ' Spoim is ©1999-2001<artlythere@...> ' (Hide Control Strip if animation is delayed.) _MaxSpoims = 120 // 120 = 4*120 actual pixels drawn DIM as double wx(_MaxSpoims) DIM as double wy(_MaxSpoims) _north = 1 'particle directions _east = 2 _south = 3 _west = 4 DIM gSpoimWorld as Long DIM gScreenGW as Long DIM gScreenDV as Long DIM lastTicks as long DIm gRect as Rect End Globals '~'1 '~'1 LOCAL FN MakeLockedGWorld(theRect as Ptr To rect, depth) dim qdErr DIM @ myGWorld as long qdErr = FN NEWGWORLD(myGWorld, depth, #theRect, 0,0,0) LONG IF (qdErr != _noErr) if myGWorld then Call DisposeGWorld(myGWorld) myGWorld = 0 Xelse long if FN LOCKPIXELS(FN GETGWORLDPIXMAP(myGWorld)) = _false if myGWorld then Call DisposeGWorld(myGWorld) myGWorld = 0 end if End if END FN = myGWorld LOCAL FN CopyBlitz(sPort&,dPort&,sRect as ptr,dRect as ptr) Call ForeColor(_BlackColor) Call BackColor(_whiteColor) CALL COPYBITS(#sPort&+2,#dPort&+2,#sRect,#dRect,_srcCopy,0) END FN '~'1 '~'1 CLEAR LOCAL ' Brightness of the 4 pixels covered by particle ' (top left, top right, bottom left, bottom right) DIM as Double btl, btr, bbl, bbr ' The fraction part of the coordinates DIM as Double fx, fy LOCAL FN wuPixel(wx as double,wy as double,invert) ' Integer coordinates of Wupixel DIM x, y ' Calculate the coordinates of the top left pixel x = FIX(wx) y = FIX(wy) ' ' Calculate the <displacement> from exact integer fx = wx - x fy = wy - y ' Calculate the brightness of each of the 4 pixels ' and multiply by the brightness parameter btl = (1-fx) * (1-fy) btr = (fx) * (1-fy) bbl = (1-fx) * (fy) bbr = (fx) * (fy) Long if invert // Light on Dark btl = btl*65535 btr = btr*65535 bbl = bbl*65535 bbr = bbr*65535 Xelse // Dark on Light btl = 65535-(btl*65535) btr = 65535-(btr*65535) bbl = 65535-(bbl*65535) bbr = 65535-(bbr*65535) End if 'Plot the pixels 'Totality of all 4 = brightness of 1 standard pixel LONG COLOR btl,btl,btl PLOT x,y LONG COLOR btr,btr,btr PLOT x+1,y LONG COLOR bbl,bbl,bbl PLOT x,y+1 LONG COLOR bbr,bbr,bbr PLOT x+1,y+1 END FN '~'1 CLEAR LOCAL DIM adp as double DIM as Double x,y LOCAL FN AnimatePixels(theTicks as long,invert) DIM @tmpWorld as long DIM @tmpDevice as long DIM direction DIM as long j ' Limit frame rate by tick checking Long if theTicks-lastTicks > 2 Call getGWorld(tmpWorld,tmpDevice) Call SetGWorld(gSpoimWorld,0) Long if invert Call BackColor(_BlackColor) Xelse Call BackColor(_WhiteColor) End if cls ' Erase Old FOR j=0 TO _MaxSpoims direction =RND(4) SELECT direction CASE _north adp = -.1 CASE _south adp = -.3 CASE _east adp = -.5 CASE _west adp = -.7 END SELECT 'randomize motion more IF MAYBE THEN adp = -adp x = wx(j) + adp 'alter x y = wy(j) - adp 'alter y FN wuPixel(x ,y,invert) 'Draw New Pixel wx(j) = wx(j) + adp wy(j) = wy(j) + adp ' use "wy(j) - adp" for more of a diagonal swimming ' motion versus random. NEXT j Call SetGWorld(tmpWorld,tmpDevice) FN CopyBlitz(gSpoimWorld,gScreenGW,gRect,gRect) lastTicks = theTicks // global lastTicks End If END FN '~'1 CLEAR LOCAL LOCAL FN loadArray DIM j FOR j=0 TO _MaxSpoims ' Fill Points array wx(j) = RND(320)+RND(10)*.1 //Starting X wy(j) = RND(320)+RND(10)*.1 //Starting Y NEXT j END FN '~'1 "Main" DIm Invert // Flag DIM system(400*400*4) // 640 K for GWorld Call SetRect(gRect,0,0,320,320) WINDOW 1, "Spoim",@gRect,_docNoGrow Call GetGworld(gScreenGW,gScreenDV) gSpoimWorld = FN MakeLockedGWorld(gRect,32) Long if gSpoimWorld FN loadArray lastTicks = FN TickCount Invert = _True// or _False DO FN AnimatePixels(FN TickCount,Invert) UNTIL FN BUTTON OR LEN(INKEY$)// Mouse or Key press END Xelse Stop "Increase Dim System Total" End If