July 06, 2020, 04:37:52 AM

### Author Topic: Plasmatic - plasma in motion  (Read 1067 times)

#### bplus ##### Plasmatic - plasma in motion
« on: January 21, 2020, 06:44:04 PM »
Code: [Select]
`'Plasmatic.bas 2020-01-21 b+ translated back to SmallBASIC after modifications to 'QB64 Plasmatic.bas b+ 2020-01-20 translated and modified from SmallBASIC'Plasma Magnifico - updated 2015-11-26 for Android modified'SmallBASIC Library > Graphics 1 > plasmajvsh.bas'  "This program creates a plasma surface, which looks oily or silky."'===========================================================================================================' '                                   Plasmatic - plasma in motion''=========================================================================================================== const xxmax = 500const yymax = 500const xoff = (xmax - xxmax) \ 2const yoff = (ymax - yymax) \ 2DIM c(360), p(6), f(6)at xoff, yoff + yymax + 20 : print "Press spacebar for new color set, esc or q to quit."label restartr = RND: g = RND: b = RND: i = 0FOR n = 1 TO 5    r1 = r: g1 = g: b1 = b    repeat: r = RND: UNTIL ABS(r - r1) > .2    repeat: g = RND: UNTIL ABS(g - g1) > .2    repeat: b = RND: UNTIL ABS(g - g1) > .2    FOR m = 0 TO 17: m1 = 17 - m        f1 = (m * r) / 18: f2 = (m * g) / 18: f3 = (m * b) / 18: c(i) = rgbf(f1, f2, f3): i = i + 1    NEXT    FOR m = 0 TO 17: m1 = 17 - m        f1 = (m + m1 * r) / 18: f2 = (m + m1 * g) / 18: f3 = (m + m1 * b) / 18: c(i) = rgbf(f1, f2, f3): i = i + 1    NEXT    FOR m = 0 TO 17: m1 = 17 - m        f1 = (m1 + m * r) / 18: f2 = (m1 + m * g) / 18: f3 = (m1 + m * b) / 18: c(i) = rgbf(f1, f2, f3): i = i + 1    NEXT    FOR m = 0 TO 17: m1 = 17 - m        f1 = (m1 * r) / 18: f2 = (m1 * g) / 18: f3 = (m1 * b) / 18: c(i) = rgbf(f1, f2, f3): i = i + 1    NEXTNEXT FOR n = 0 TO 5    p(n).x = RND * xxmax: p(n).y = RND * yymax: p(n).dx = RND * 2 - 1: p(n).dy = RND * 2 - 1    f(n) = RND * .1NEXT WHILE 1    k = inkey    if k = " " then goto restart    if k = "q" or asc(k) = 27 then end    FOR i = 0 TO 5        p(i).x = p(i).x + p(i).dx        IF p(i).x > xxmax OR p(i).x < 0 THEN p(i).dx = -1*p(i).dx        p(i).y = p(i).y + p(i).dy        IF p(i).y > yymax OR p(i).y < 0 THEN p(i).dy = -1*p(i).dy    NEXT    FOR y = 0 TO yymax - 1 STEP 3        FOR x = 0 TO xxmax - 1 STEP 3            d = 0            FOR n = 0 TO 5                dx = x - p(n).x: dy = y - p(n).y                k = SQR(dx * dx + dy * dy)                d = d + (SIN(k * f(n)) + 1) / 2            NEXT n: d = d * 60            rect x + xoff, y + yoff STEP 3, 3, c(d) filled        NEXT    NEXT    showpageWEND`

#### johnno56 ##### Re: Plasmatic - plasma in motion
« Reply #1 on: January 22, 2020, 12:03:18 AM »
Cool... I even like the colours... Nicely done!
May your journey be free of incident.

Live long and prosper.

#### bplus ##### Re: Plasmatic - plasma in motion
« Reply #2 on: January 22, 2020, 01:44:10 AM »
Thanks Johnno, here's a clock:
Code: [Select]
`'Plasmatic Digital Clock for SmallBASIC 64 bit b+ 2020-01-21 from' from Digital Plasmatic Clock.bas  b+ 2020-01-20 QB64'=======================================================================''                        press spacebar for new coloring set''=======================================================================CONST xxmax = 850const yymax = 200const sq = 25CONST dat = "1110111000001101111100011111100101110111011101101001001111111111011011"const xoffset = (xmax - xxmax) \ 2const yoffset = (ymax - yymax) \ 2DIM c(360), p(6), f(6)label restartr = RND: g = RND: b = RND: i = 0FOR n = 1 TO 5    r1 = r: g1 = g: b1 = b    repeat: r = RND: UNTIL ABS(r - r1) > .2    repeat: g = RND: UNTIL ABS(g - g1) > .2    repeat: b = RND: UNTIL ABS(g - g1) > .2    FOR m = 0 TO 17: m1 = 17 - m        f1 = (m * r) / 18: f2 = (m * g) / 18: f3 = (m * b) / 18: c(i) = rgbf(f1, f2, f3): i = i + 1    NEXT    FOR m = 0 TO 17: m1 = 17 - m        f1 = (m + m1 * r) / 18: f2 = (m + m1 * g) / 18: f3 = (m + m1 * b) / 18: c(i) = rgbf(f1, f2, f3): i = i + 1    NEXT    FOR m = 0 TO 17: m1 = 17 - m        f1 = (m1 + m * r) / 18: f2 = (m1 + m * g) / 18: f3 = (m1 + m * b) / 18: c(i) = rgbf(f1, f2, f3): i = i + 1    NEXT    FOR m = 0 TO 17: m1 = 17 - m        f1 = (m1 * r) / 18: f2 = (m1 * g) / 18: f3 = (m1 * b) / 18: c(i) = rgbf(f1, f2, f3): i = i + 1    NEXTNEXTFOR n = 0 TO 5    p(n).x = RND * xxmax: p(n).y = RND * xymax: p(n).dx = RND * 2 - 1: p(n).dy = RND * 2 - 1    f(n) = RND * .1NEXTWHILE 1    k = inkey    IF k = " " THEN GOTO restart    if k = "q" or asc(k) = 27 then end    FOR i = 0 TO 5        p(i).x = p(i).x + p(i).dx        IF p(i).x > xxmax OR p(i).x < 0 THEN p(i).dx = -p(i).dx        p(i).y = p(i).y + p(i).dy        IF p(i).y > yymax OR p(i).y < 0 THEN p(i).dy = -p(i).dy    NEXT    FOR y = 0 TO yymax - 1 STEP 4        FOR x = 0 TO xxmax - 1 STEP 4            d = 0            FOR n = 0 TO 5                dx = x - p(n).x: dy = y - p(n).y                k = SQR(dx * dx + dy * dy)                d = d + (SIN(k * f(n)) + 1) / 2            NEXT n: d = d * 60            rect x + xoffset, y + yoffset STEP 4, 4, c(d) filled        NEXT    NEXT    FOR j = 1 TO 3        IF j = 1 THEN            klr = 15: offset = -2        ELSEIF j = 2 THEN            klr = rgb(34, 34, 34): offset = 2        ELSE            klr = rgb(190, 190, 190): offset = 0        END IF        FOR n = 1 TO 8 'clock digits over background            IF MID(TIME, n, 1) = ":" THEN                rect (n - 1) * 4 * sq + 2 * sq + xoffset + offset, sq + sq + yoffset + offset STEP sq, sq, klr filled                rect (n - 1) * 4 * sq + 2 * sq + xoffset + offset, sq + 4 * sq + yoffset + offset STEP sq, sq, klr filled            ELSE                drawC (n - 1) * 4 * sq + sq + xoffset + offset, sq + yoffset + offset, MID(dat, VAL(MID(TIME, n, 1)) * 7 + 1, 7), klr            END IF        NEXT    NEXT    showpageWENDSUB drawC (x, y, c, cr)    FOR m = 1 TO 7        IF VAL(MID(c, m, 1)) THEN            SELECT CASE m                CASE 1: rect x, y STEP sq, 3 * sq, cr filled                CASE 2: rect x, y + 2 * sq STEP sq, 4 * sq, cr filled                CASE 3: rect x, y STEP 3 * sq, sq , cr filled                CASE 4: rect x, y + 2 * sq STEP 3 * sq, sq , cr filled                CASE 5: rect x, y + 5 * sq  STEP 3 * sq, sq , cr filled                CASE 6: rect x + 2 * sq, y  STEP sq, 3 * sq , cr filled                CASE 7: rect x + 2 * sq, y + 2 * sq STEP sq, 4 * sq , cr filled            END SELECT        END IF    NEXTEND SUB`

#### johnno56 ##### Re: Plasmatic - plasma in motion
« Reply #3 on: January 22, 2020, 08:03:51 AM »
Cool... Watching the seconds tick by, with the background moving, is almost hypnotic... I watched it for almost a minute and it didn't effect me effect me effect me
May your journey be free of incident.

Live long and prosper.

#### chrisws

• Jr. Member
•  • Posts: 47 ##### Re: Plasmatic - plasma in motion
« Reply #4 on: January 22, 2020, 10:27:58 PM »
You won the internet for the day with that one, amazing #### Aurel ##### Re: Plasmatic - plasma in motion
« Reply #5 on: January 23, 2020, 03:59:48 PM »
Yo bPlus ....very nice

#### bplus ##### Re: Plasmatic - plasma in motion
« Reply #6 on: January 23, 2020, 04:19:23 PM »
Thanks guys, we are continuing experiments and learning to get some control over the stuff we call plasma. #### bplus ##### Re: Plasmatic - plasma in motion
« Reply #7 on: January 24, 2020, 05:40:51 PM »
And the results of study are in:

A new updated Plasmatic with (255^3) ^ 2 more color options! Plus color palette creation demystified (I hope) and code more completely documented with comments. This demo contrasts the Traditional high contrast Black and White Plasma palette with the newly updated full color range options for color palette creation for plasma.

Code: [Select]
`'Updated Plasmatic with Full Color Mixing.bas translated to SmallBASIC b+ 2020-01-24' from QB64 "Color Mixing 4 Plasmatic" ' b+ 2020-01-23' continued study of what makes Plasmatic tick, ' here the color palette is updated for full range of color mixing options,' PLUS I think color band creation for palette has been a little demystified,' PLUS more fully commented code.' common shared unchanging variables and static arrays const xxmax = 500 'need smaller screen for interpreted Basic const yymax = 400const xoff = (xmax - xxmax) \ 2const yoff = (ymax - yymax) \ 2dim c(360), p(6), f(6)'start programrandomize timerlabel restart 'select rgb1 and rgb2 based on mode of color mixingIF mode = 0 THEN 'new plasma option ANY color for border and ANY color for middle     r1 = RND * 255: g1 = RND * 255: b1 = RND * 255: r2 = RND * 255: g2 = RND * 255: b2 = RND * 255ELSE ' traditional high contrast plasma black borders, white centers    r1 = 0: g1 = 0: b1 = 0: r2 = 255: g2 = 255: b2 = 255 'regular PlasmaEND IF'create 6 x 60 bands of color palette based on coloring mode (rgb1 set and rgb2 set)FOR i = 0 TO 360    IF i MOD 60 = 0 THEN r = RND * 255: g = RND * 255: b = RND * 255 'start new color band    m = i MOD 60 'color bands have width of 60, 4 stages    if m < 15 then ' 1st stage increase rgb1 towards rgb color in 15 steps       c(i) = midInk(r1, g1, b1, r, g, b, m / 15)    elif m < 30 ' 2nd stage increase rgb color towards rgb2 set in 15 steps       c(i) = midInk(r, g, b, r2, g2, b2, (m - 15) / 15)    elif m < 45 ' 3rd stage decrease rgb2 color back to rgb color in 15 steps       c(i) = midInk(r2, g2, b2, r, g, b, (m - 30) / 15)    elif m < 60 ' 4th and finally decrease rgb back to starting rgb1 set in 15 steps      c(i) = midInk(r, g, b, r1, g1, b1, (m - 45) / 15)    END ifNEXT' behind the scenes variables for motion, weighting and shaping color mixingFOR n = 0 TO 5     p(n).x = RND * xxmax: p(n).y = RND * yymax: p(n).dx = RND * 2 - 1: p(n).dy = RND * 2 - 1 'create points    f(n) = .1 * RND ' create the inverse size and weight factor, large f = small globs but carry weightNEXT'screen labeling 3 lines for title above, 2 lines instruction belowclsat xoff, yoff - 60if mode = 0 then   CP yoff - 60, "New Color Options for Plasma:" else   CP yoff - 60, "Traditional High Contrast Plasma: Black Borders and White Centers"end ifCP yoff - 40, "Borders: RGB(" + str(r1 \ 1) + ", " + str(g1 \ 1) + ", " + str(b1 \ 1) + ")"CP yoff - 20, "Centers: RGB(" + str(r2 \ 1) + ", " + str(g2 \ 1) + ", " + str(b2 \ 1) + ")"CP yoff + yymax + 10, "Press t to toggle between Traditional and New Color Options Plasma" CP yoff + yymax + 30, "Press spacebar to get a new color set."'plasma in motion    WHILE 1    'get user input choices    k = INKEY     IF k = " " THEN GOTO restart    if k = "q" or asc(k) = 27 then end    IF k = "t" THEN mode = 1 - mode: GOTO restart        'move points    FOR i = 0 TO 5        p(i).x = p(i).x + p(i).dx        IF p(i).x > xxmax OR p(i).x < 0 THEN p(i).dx = -p(i).dx        p(i).y = p(i).y + p(i).dy        IF p(i).y > yymax OR p(i).y < 0 THEN p(i).dy = -p(i).dy    NEXT    'calculate each screen x, y color based on distance to 6 points    FOR y = 0 TO yymax - 1 STEP 3        FOR x = 0 TO xxmax - 1 STEP 3            d = 0            FOR n = 0 TO 5                dx = x - p(n).x: dy = y - p(n).y                k = SQR(dx * dx + dy * dy)                d = d + (SIN(k * f(n)) + 1) / 2            NEXT n: d = d * 60            rect x + xoff, y + yoff STEP 3, 3, c(d) filled        NEXT    NEXT    showpageWEND'report the color number between rgb1 and rgb2 at fraction fr from rgb1func midInk(r1, g1, b1, r2, g2, b2, fr)  midInk = rgb(r1+(r2-r1)*fr, g1+(g2-g1)*fr, b1+(b2-b1)*fr)end'Center Print at topYpixel down from topsub CP(topYpixel, stringg)  at (xmax - txtw(stringg))/2, topYpixel :print stringgend sub`

#### Aurel ##### Re: Plasmatic - plasma in motion
« Reply #8 on: January 31, 2020, 09:08:51 AM »
Markl...why this program work very slowly somehow?

#### bplus ##### Re: Plasmatic - plasma in motion
« Reply #9 on: January 31, 2020, 03:27:31 PM »
Markl...why this program work very slowly somehow?
I mentioned it was meant for SmallBASIC 64 bit, perhaps I should have emphasized it:

Plasmatic stuff meant for SmallBASIC 64 BIT I look forward to day someone else posts code for SmallBASIC here at this forum.

Anybody know the Moody Blues song, Watching and Waiting?

#### Aurel ##### Re: Plasmatic - plasma in motion
« Reply #10 on: January 31, 2020, 05:55:22 PM »
Wait a moment ...dude
I tried both ...32bit and 64 bit versions on both
win7 . 32/64 bit
win10 32/64 systems
yes I have all of them
and still work slowly...soo please without patronizing .. #### Aurel ##### Re: Plasmatic - plasma in motion
« Reply #11 on: January 31, 2020, 06:24:12 PM »
if you want listen real/hot lady/bitc**

#### bplus ##### Re: Plasmatic - plasma in motion
« Reply #12 on: February 01, 2020, 12:21:56 AM »
Well that's funny, I checked out the code posted running it in SmallBASIC version 12.17 64 bit and it was not recognizing key presses The code runs slowish but not bad for interpreter.

So I check it out in version 12.13, yep! works fine with key presses.

So I check it out in new editor, there it runs slow as the dickens but key presses are recognized.

#### chrisws

• Jr. Member
•  • Posts: 47 ##### Re: Plasmatic - plasma in motion
« Reply #13 on: February 01, 2020, 04:52:14 AM »
Well that's funny, I checked out the code posted running it in SmallBASIC version 12.17 64 bit and it was not recognizing key presses The code runs slowish but not bad for interpreter.
Oh snap it works fine in the linux version I will fix and push another update.
I will see what can be done to make the FLTK version a bit faster.

(stick around for the epic guitar solo towards the end)

#### bplus ##### Re: Plasmatic - plasma in motion
« Reply #14 on: February 01, 2020, 03:31:52 PM »
Thanks Chris, great song yeah nice guitar hope you can do something with Editor speed but I'm not worried.

stick around for whole album ;-))