Small 25 line program
#1
I found this on the "mmbasic" site and converted it to run on qb64.

Screen 12
n = 255
r = (2 * pi) / 235
x = 0
v = 0
t = 0
sz = 200
s = 0
scrw = 640: scrh = 480
sw = scrw / sz: sh = scrh / sz
offset = scrh / 4.5
Do
    Cls
    For i = 50 To n
        For j = 50 To n
            u = Sin(i + v) + Sin(r * i + x)
            v = Cos(i + v) + Cos(r * i + x)
            x = u + t
            q = scrw / 2 + u * offset
            a = scrh / 2 + v * offset
            PSet (q, a), _RGB32(Int(Rnd * 256), Int(Rnd * 256), Int(Rnd * 256))
        Next j
    Next i
    t = t + .025
Loop


A screen shot really does not look as good so run it and see.
Reply
#2
What happens if we tweak numbers a bit and give pi a non zero value?
Code: (Select All)
Screen 12
pi = 3.1415
n = 200
r = (2 * pi) / 100
x = 0
v = 0
t = 0
sz = 200
s = 0
scrw = 640: scrh = 480
sw = scrw / sz: sh = scrh / sz
offset = scrh / 4.5
Do
    Cls
    For i = 50 To n
        c~& = _RGB32(Int(Rnd * 200) + 55, Int(Rnd * 200) + 55, Int(Rnd * 200) + 55)
        For j = 50 To n
            u = Sin(i + v) + Sin(r * i + x)
            v = Cos(i + v) + Cos(r * i + x)
            x = u + t
            q = scrw / 2 + u * offset
            a = scrh / 2 + v * offset
            Circle (q, a), 1, c~&
            lastq = q: lasta = a
        Next j
    Next i
    t = t + .001
    _Display
    _Limit 30
Loop

EDIT: more dramatic color change
b = b + ...
Reply
#3
Ok , that is much better. Thanks.
Reply
#4
Heh, I changed it a little more ;-))
b = b + ...
Reply
#5
(11-15-2022, 06:40 PM)Gadgetjack Wrote: I found this on the "mmbasic" site and converted it to run on qb64.

...snip...

A screen shot really does not look as good so run it and see.

Thanks for sharing that!  I really like it.  Ridiculously mesmerising.  

BAM version with an added "_DISPLAY" statement:
Reply
#6
That does look good Charlie!
b = b + ...
Reply
#7
(11-15-2022, 08:06 PM)bplus Wrote: That does look good Charlie!

Man, I love these types of small BASIC programs that do cool stuff.  I could watch that animation and/or fiddle with that program all day.
Reply
#8
I am very impressed. In just a few minutes my little program got so much better. Thanks to all.
Reply
#9
(11-15-2022, 06:40 PM)Gadgetjack Wrote: I found this on the "mmbasic" site and converted it to run on qb64.
A screen shot really does not look as good so run it and see.
Change "pi" to "_pi", use underscore in front of fake constant.

This function should be covered by Steve in "keyword of the day" threads. Probably "mmbasic" has "pi" as predefined constant.
Reply
#10
I couldn't resist changing it for "guided" randomization:

Code: (Select All)
dim pr(1 to 10) as _byte
dim as integer rr, gg, bb, rc, gc, bc
scrw = 640: scrh = 480
for i = 1 to 10
    read pr(i)
next
rr = 32: gg = 32: bb = 32
rc = 1: gc = 4: bc = 7
Screen _newimage(scrw, scrh, 32)
n = 255
r = (2 * _PI) / 235
x = 0
v = 0
t = 0
sz = 200
s = 0
sw = scrw / sz: sh = scrh / sz
offset = scrh / 4.5
for o = 1 to 8
    Cls
    For i = 50 To n
        rr = rr + pr(rc)
        if rr > 255 then rr = rr - 224
        rc = rc + 1
        if rc > 10 then rc = 1
        gg = gg + pr(gc)
        if gg > 255 then gg = gg - 224
        gc = gc + 2
        if gc > 10 then gc = gc - 2
        bb = bb + pr(bc)
        if bb > 255 then bb = bb - 224
        bc = bc + 3
        if bc > 10 then bc = bc - 3
        if rc = bc then
            gc = gc + 1
            if gc > 10 then gc = 1
        end if
        For j = 50 To n
            u = Sin(i + v) + Sin(r * i + x)
            v = Cos(i + v) + Cos(r * i + x)
            x = u + t
            q = scrw / 2 + u * offset
            a = scrh / 2 + v * offset
            PSet (q, a), _RGB(rr, gg, bb)
        Next j
    Next i
    t = t + .025
    _delay 1
next

data 5, 7, 11, 13, 17, 19, 23, 29, 31, 37
Reply




Users browsing this thread: 1 Guest(s)