A function I am working on that draws fuzzy things. It became a bit more complex than I initially expected so I might rewrite it useing types intead of arrays. I also plan on adding rotation and improving the speed. Anyway here it is:
;GLOBAL ARRAYS NEEDED
Dim fuzzer(10, 360), fuzzdir(10, 360)
;---------------------------------------------------------------------;
;***************************** DEMO **********************************;
;---------------------------------------------------------------------;
Graphics 1024, 768
SetBuffer BackBuffer()
SeedRnd MilliSecs()
Color 200, 50, 50
FUZZ_INIT(1, 100, 360)
FUZZ_INIT(2, 100, 360)
FUZZ_INIT(3, 100, 360)
FUZZ_INIT(4, 100, 360)
FUZZ_INIT(5, 100, 360)
While Not KeyHit(1)
Cls
FUZZY_CIRCLE(1, 300, 300, 100, 160, 50, 5, 1)
FUZZY_CIRCLE(2, 800, 500, 100, 360, 50, 5, 0)
FUZZY_CIRCLE(3, 550, 200, 50, 50, 40, 3, 0)
FUZZY_CIRCLE(4, 550, 200, 50, 50, 10, 1, 0)
FUZZY_CIRCLE(5, 400, 600, 100, 20, 10, 1, 0)
Flip
Wend
;---------------------------------------------------------------------;
;*************************** FUNCTIONS *******************************;
;---------------------------------------------------------------------;
Function FUZZ_INIT(number, intense, fuzz)
For i = 1 To fuzz
fuzzer(number, i) = Rand(0, intense)
Next
End Function
;------------------------------;
Function FUZZY_CIRCLE(number, cx, cy, rad, fuzz, intense, vibration, randy)
angstep# = Float(360) / Float(fuzz)
first_x = (cx - (rad +fuzzer(number, 1)) * Cos(deg#))
first_y = (cy - (rad +fuzzer(number, 1)) * Sin(deg#))
this_x = (cx - (rad +fuzzer(number, 1)) * Cos(deg#))
this_y = (cy - (rad +fuzzer(number, 1)) * Sin(deg#))
FUZZ_MOVE(number, 1, intense, vibration, randy)
LockBuffer
For i = 2 To fuzz
deg# = deg# + angstep#
last_x = this_x
last_y = this_y
FUZZ_MOVE(number, i, intense, vibration, randy)
this_x = (cx - (rad +fuzzer(number, i)) * Cos(deg#))
this_y = (cy - (rad +fuzzer(number, i)) * Sin(deg#))
Line last_x, last_y, this_x, this_y
Next
Line this_x, this_y, first_x, first_y
UnlockBuffer
End Function
;-------------------------------;
Function FUZZ_MOVE(number, i, intense, vibration, randy)
If fuzzdir(number, i) = 0
fuzzer(number, i) = fuzzer(number, i) + vibration +Rand(0, randy)
Else
fuzzer(number, i) = fuzzer(number, i) - vibration -Rand(0, randy)
EndIf
If fuzzer(number, i) >= intense
fuzzdir(number, i) = 1
Else If fuzzer(number, i) <= -intense
fuzzdir(number, i) =0
EndIf
End Function