array-less simulacra

Post your FreeBASIC source, examples, tips and tricks here. Please don’t post code without including an explanation.
dafhi
Posts: 1682
Joined: Jun 04, 2005 9:51

array-less simulacra

Code: Select all

``````/'
array-less simulacra - 2024 Apr 30  by dafhi

inspired by one line code challenge
https://www.freebasic.net/forum/viewtopic.php?t=32637

simulacra means likeness, semblance ..

'/

function modu( in as double, m as double = 1 ) as double
return in - m * int( in / m )
end function

sub _temporals( byref s as double, byref f as double, t as double )
randomize int(t)
f = rnd             '' p1
randomize int(t)+1

'  p1 +    lerp     * (p2 - p1)
f = f + (t - int(t)) * (rnd - f)

s = t '' graph: s is horizontal, and f vertical
end sub

dim as short w=800, h=600

screenres w,h,32

const Tau = 8*atn(1)

const win_extend = 200
const exBy2 = win_extend / 2

dim as short w_ext = w + win_extend
dim as short h_ext = h + win_extend

dim as double x,y,f,s,m,cosa,sina,t,t0=timer

do
t = timer-t0

screenlock
cls

for seed as long = 0 to 1999

randomize seed '' store some pre-temporal randoms
dim as double _x = rnd, _y = rnd, _c = rnd, _r = rnd, _a = rnd*tau

var freq = 9
_temporals s,f, seed + freq * t * (_c + .3) '' _c for random speed
' "seed +" for high entropy likeness at t=0

'' direction
m = 19 * s / freq
cosa = cos(_a) * m
sina = sin(_a) * m

x = _x * w_ext + cosa
y = _y * h_ext + sina

_r = .7 + f * 50 * _x*_y*_c*_r * (h/800) '' multiplied rnds for non-linear

circle ( modu(x,w_ext)-exBy2, modu(y,h_ext)-exBy2 ),  _r,  _c * culng(-1)

next
screenunlock

sleep 1
if inkey<>"" then end
loop while t < 30

? "fin!"
sleep 1500
``````