Author Topic: Ectoplasm  (Read 11539 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Ectoplasm
« on: June 22, 2019, 10:06:39 pm »
Just picked up a case today at Retro.

Code: QB64: [Select]
  1. _TITLE "Ectoplasm" 'mod of Galileo's at Retro 2019-06-22 B+
  2. 'open window 256, 256
  3. SCREEN _NEWIMAGE(256, 256, 32)
  4. 'sh=peek("winheight")
  5. sh = _HEIGHT
  6. 'sw=peek("winwidth")
  7. sw = _WIDTH
  8. d = 1
  9.     'tm = peek("secondsrunning")
  10.     tm = TIMER(.001)
  11.     dr = ran(256): dg = ran(256): db = ran(256)
  12.     w = w + 5 / 83 '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< get things moving
  13.     FOR y = 0 TO sh
  14.         FOR x = 0 TO sw
  15.             vl = SIN(distance(x + tm, y, 128, 128) / 8 + w)
  16.             vl = vl + SIN(distance(x, y, 64, 64) / 8)
  17.             vl = vl + SIN(distance(x, y + tm / 7, 192, 64) / 7)
  18.             vl = vl + SIN(distance(x, y, 192, 100) / 8)
  19.             clr = 255 / (1.00001 * ABS(vl))
  20.             r = .9 * ABS(clr - dr): g = .4 * ABS(clr - dg): b = .5 * ABS(clr - db)
  21.             'COLOR r, g, b
  22.             'dot x, y
  23.             PSET (x, y), _RGB32(r, g, b)
  24.         NEXT
  25.     NEXT
  26.     IF w > 1000 OR w < -1000 THEN w = 0: d = d * -1
  27.     _DISPLAY
  28.     _LIMIT 200
  29. FUNCTION distance (x1, y1, x2, y2) '//between two points x1,y1 and x2,y2
  30.     distance = ((x1 - x2) ^ 2 + (y1 - y2) ^ 2) ^ .5
  31. FUNCTION ran% (sing)
  32.     ran% = INT(RND * sing) + 1
  33.  
  34.  

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Ectoplasm
« Reply #1 on: June 22, 2019, 10:33:14 pm »
Way cool! I wish I kept all the programs I used to mess with in the 90's. The old newsgroup comp.lang.basic.misc used to punch out around one a day.
« Last Edit: June 22, 2019, 10:39:46 pm by SierraKen »

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Ectoplasm
« Reply #2 on: June 23, 2019, 12:34:32 am »
Cool bplus!
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Ectoplasm
« Reply #3 on: June 23, 2019, 05:59:48 am »
Hi BPlus, again nice work. Just for my curiosity i try making it faster and then... compiling it under 1.3 and under 0.978.... Look  yourself to the speed diference.

Source, which is used for this test is attached.

Code: QB64: [Select]
  1. _TITLE "Ectoplasm" 'mod of Galileo's at Retro 2019-06-22 B+
  2. 'open window 256, 256
  3. SCREEN _NEWIMAGE(256, 256, 32)
  4. DIM m AS _MEM, x AS SINGLE, y AS SINGLE, vl AS SINGLE, r AS SINGLE, clr AS SINGLE, klr AS _UNSIGNED LONG, tm AS SINGLE, dr AS SINGLE, dg AS SINGLE, db AS SINGLE, w AS SINGLE, sh AS SINGLE, sw AS SINGLE
  5. m = _MEMIMAGE(0)
  6.  
  7. 'sh=peek("winheight")
  8. sh = _HEIGHT - 1
  9. 'sw=peek("winwidth")
  10. sw = _WIDTH - 1
  11. d = 1
  12.     'tm = peek("secondsrunning")
  13.     tm = TIMER(.001)
  14.     dr = ran(256): dg = ran(256): db = ran(256)
  15.     w = w + 5 / 83 '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< get things moving
  16.     REDIM scr(255, 255) AS _UNSIGNED LONG
  17.     FOR y = 0 TO sh
  18.         FOR x = 0 TO sw
  19.             vl = SIN(distance(x + tm, y, 128, 128) / 8 + w)
  20.             vl = vl + SIN(distance(x, y, 64, 64) / 8)
  21.             vl = vl + SIN(distance(x, y + tm / 7, 192, 64) / 7)
  22.             vl = vl + SIN(distance(x, y, 192, 100) / 8)
  23.             clr = 255 / (1.00001 * ABS(vl))
  24.             r = .9 * ABS(clr - dr): g = .4 * ABS(clr - dg): b = .5 * ABS(clr - db)
  25.             'COLOR r, g, b
  26.             'dot x, y
  27.             '     PSET (x, y), _RGB32(r, g, b)
  28.             klr~& = _RGB32(r, g, b)
  29.             scr(x, y) = klr~&
  30.         NEXT
  31.     NEXT
  32.     IF w > 1000 OR w < -1000 THEN w = 0: d = d * -1
  33.     _MEMPUT m, m.OFFSET, scr()
  34.  
  35.     ' _DISPLAY
  36.     ' _LIMIT 200
  37.  
  38.  
  39. FUNCTION distance (x1, y1, x2, y2) '//between two points x1,y1 and x2,y2
  40.     distance = ((x1 - x2) ^ 2 + (y1 - y2) ^ 2) ^ .5
  41. FUNCTION ran% (sing)
  42.     ran% = INT(RND * sing) + 1
  43.  
  44.  
  45.  
* Speed difference 1.3 left vs 0.978 right.wmv (Filesize: 3.47 MB, Downloads: 185)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Ectoplasm
« Reply #4 on: June 23, 2019, 08:22:29 am »
Hi Petr,

What is .978 an older version of QB64?

I am not seeing any great difference between two codes on my system?? Both give the fan a workout, maybe a little less with yours, Petr.

BTW this not really my work, I added w to get the stuff to move and fiddled with numbers until I got the cool glowing white effect.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Ectoplasm
« Reply #5 on: June 23, 2019, 08:35:46 am »
Hi, yeah, it's an older version of QB64. Apparently, it didn't have such a so big bug tracking in the compiled C code, so it goes a quarter faster in the old version. Maybe it will compare when a newer version comes out after RhoSigma's $CHECKING OFF upgrade.  I talk about https://www.qb64.org/forum/index.php?topic=1348.0, so maybe then is 1.3 faster than old version.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Ectoplasm
« Reply #6 on: June 23, 2019, 09:15:50 am »
Cool demo... I stared at it for several minutes, just to see if it would mess up my eyesight, nothing. It didn't even effect me effect me....
Logic is the beginning of wisdom.

FellippeHeitor

  • Guest
Re: Ectoplasm
« Reply #7 on: June 23, 2019, 09:28:35 am »
This is gorgeous! All these plasma effects with minimal lines have always puzzled me as I have no idea what's going on behind all the math. It just makes it more magical to me after all.

I stared at it for several minutes, just to see if it would mess up my eyesight

What did I just read, johnno56? 🤣

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Ectoplasm
« Reply #8 on: June 23, 2019, 09:47:30 am »
... at least 'you' can still read... lol
Logic is the beginning of wisdom.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Ectoplasm
« Reply #9 on: June 23, 2019, 02:06:53 pm »
Yeah
I can say Cool for your plasma!
Sorry but my first thought was this https://en.wikipedia.org/wiki/Blood_plasma#/media/File:FreshFrozenPlasma.JPG and it seems so different from those showed by code of Bplus and by code of Petr.
Thanks to you I have seen cool graphics and I have learned that also in english plasma word can have three different meanings https://www.vocabulary.com/dictionary/plasma

Here over the programming there are exchanges of culture! Very Cool!
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Ectoplasm
« Reply #10 on: June 23, 2019, 02:21:51 pm »
Hi TempodiBasic,

Here is another definition for ectoplasm:
Quote
a supernatural viscous substance that is supposed to exude from the body of a medium during a spiritualistic trance and form the material for the manifestation of spirits.


Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Ectoplasm
« Reply #11 on: June 23, 2019, 02:32:56 pm »
Hey Bplus
you're right but Spiritismhttps://en.wikipedia.org/wiki/Spiritism was cool in the 1900 (or before it?) and Gosthbusters is in the 1980 https://en.wikipedia.org/wiki/Ghostbusters. To what ectoplasm  do you refer between these two last?
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
« Last Edit: June 23, 2019, 02:38:42 pm by bplus »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Ectoplasm
« Reply #13 on: June 23, 2019, 06:51:31 pm »
Programming isn't difficult, only it's  consuming time and coffee

Offline _vince

  • Seasoned Forum Regular
  • Posts: 422
    • View Profile
Re: Ectoplasm
« Reply #14 on: June 28, 2019, 08:03:03 pm »
This is gorgeous! All these plasma effects with minimal lines have always puzzled me as I have no idea what's going on behind all the math. It just makes it more magical to me after all.

Lovely article here:  http://www.petesqbsite.com/sections/tutorials/zines/qbcm/17-plasmas.html