Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Color waves
'wavy test fcirc.txt for Naalaa 6

' try a translation of a translation
' Wavy with Plasma.bas for QB64 fork (B+=MGA) 2017-05-05
' Wavy with Plasma Treatment.bas SmallBASIC 0.12.9 (B+=MGA) 2017-05-03
' from: animated circles started by Admin at SdlBasic 2017-05-03
' I added Plasma treatment and spacebar  changer


' Instructions: press spacebar for new injection of plasma


xmax 800
ymax 600
DPI# 6.283032
PHIDELTA# 0.4188688
PHISTEP# 0.1256606
largeRADIUS# 20.0
SMALL_R# 20.0
W# 800.0
H# 600.0

cN# = 1.0


set window 200, 40, xmax, ymax
set redraw 0
current_phi# = 0.0
while 1
    if inkey(1) = 32
        cN# = 1.0
    current_phi# = current_phi# + PHISTEP#
    x# = 0.0
    while x# <= (W# + largeRADIUS#)
        y# = 0.0
        while y# <= (W# + largeRADIUS#)
            phiIndex# = float#(int(x# + y#) % int(2.0 * W#)) / largeRADIUS#
            phi# = phiIndex# * PHIDELTA# + current_phi#
            xball# = cos(phi#) * largeRADIUS# + x#
            yball# = sin(phi#) * largeRADIUS# + y#
            _DrawFilledCircle int(xball#), int(yball#), int(SMALL_R#)
            y# = y# + DISTANCE#
        x# = x# + DISTANCE#
    wait 100

function rrnd#(x)
    return float#(rnd(10000))/10000.0

procedure changePlasma()
    cN# = cN# + 1.0
    set color int(127.0 + 127.0 * sin(pR# * cN#)), int(127.0 + 127.0 * sin(pG# * cN#)), int(127.0 + 127.0 * sin(pB# * cN#))

procedure resetPlasma()
    pR# = rrnd#(1)         
    pG# = rrnd#(1)
    pB# = rrnd#(1)

'very fast but  not round specially smaller circles
procedure DrawFilledCircle(x0, y0, radius)
    x = radius
    y = 0
    err = 0
    while x >= y
        x2 = x*2; y2 = y*2
        draw rect x0 - x, y0 + y, x2, 1, true
        draw rect x0 - y, y0 + x, y2, 1, true
        draw rect x0 - x, y0 - y, x2, 1, true
        draw rect x0 - y, y0 - x, y2, 1, true
        y = y + 1
        err = err + 1 + 2*y
        if 2*(err - x) + 1 > 0
            x = x - 1
            err = err + 1 - 2*x
Wow took awhile to get this going.
b = b + geberation
"Doctor. I'm seeing spots before my eyes!"


ERROR on line 40:

  Undefined symbol "resetPlasma"
Hi Rick,

I just tried copy/paste of code from forum and something is causing Naalaa 6 to bug out!

My fan is still running!

Let's try an attachment:

.txt   wavy test fcirc.txt (Size: 2.14 KB / Downloads: 5)

WTF? That's not working either!

Append: Guess I have to run the text file through a filter to see what the forum is adding to the file to screw it up. The file runs fine directly from disk.

(copied / pasted file from Naalaa editor to this forum editor, all tabs or spaces at start of lines ceased to be.)

Heck that doesn't even work!

There are differences in tabs and carriage returns.

Append: try a zip file:

.zip   wavy test (Size: 1.06 KB / Downloads: 6)

Ah! that works!

A lesson learned: If Naalaa's keywords aren't colored blue in it's editor, then it is not going to compile correctly.
b = b + geberation
OK, That worked.

 I hope we don't have a forum meltdown.
Hi Rick,

Thanks for feedback! For a test, I copy / pasted your rrrcube into Naalaa and everything seems to be working fine.

So what did I do on my end? I ran the wavey file through Notepad++ to clean up the indentations. I did run that file again through Naalaa to make sure it worked and it did but I suspect Notepad++ did something with unseen characters. I compared the files from here and my original using WinMerge and all indentations were flagged yellow (to indicate a difference between files) but all the words were the same.
b = b + geberation
May I recommend you to use the 'draw ellipse <x>, <y>, <radius_x>, <radius_y>, <filled>' command? It's a bit faster Smile

Copying and pasting worked well here. But I'm stuck on Linux - at the moment I have no Windows computer.

Probably the text gets converted to UTF8 or some other unicode-representation on Windows, and naalaa can only handle ASCII/extended ASCII.

Very nice demo Smile
Oh ouch! You make 'being stuck on Linux' sound like a bad thing... lol


ps: I tried the 'draw ellipse' command and the speed improvement was bit quicker...
Ah the ellipse command! Yes, the circle is but a special case of that!  Cool

Thanks for tip Marcus.

Hey, Johnno don't worry, I am stuck on Windows.  Big Grin
b = b + geberation
Ohhhh! Pretty! Very math-y though! Haha. Reading the code made my eyes glaze more than the scintillating colors. lol

Forum Jump:

Users browsing this thread: 2 Guest(s)