Author Topic: Plasma Waves  (Read 5367 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Plasma Waves
« on: July 21, 2017, 11:18:54 pm »
Press spacebar for new sea:
Code: QB64: [Select]
  1. 'Wavy with Plama.bas for QB64 fork (B+=MGA) 2017-05-05
  2. ' Wavy with Plasma Treatment.bas SmallBASIC 0.12.9 (B+=MGA) 2017-05-03
  3. ' from: animated circles started by Admin at SdlBasic 2017-05-03
  4. ' I added Plasma treatment and spacebar  changer
  5.  
  6.  
  7. '===================================================================
  8.  
  9. ' Instructions: press spacebar for new injection of plasma
  10.  
  11. '==================================================================
  12.  
  13. CONST sqr12! = .5 ^ .5
  14. CONST xmax = 1100
  15. CONST ymax = 700
  16. CONST DPI = 3.141516 * 2
  17. CONST PHIDELTA = DPI / 15
  18. CONST PHISTEP = DPI / 50
  19. CONST RADIUS = 20
  20. CONST SMALL_R = 20
  21. CONST DISTANCE = 23
  22. CONST W = xmax
  23. CONST H = ymax
  24.  
  25. SCREEN _NEWIMAGE(xmax, ymax, 32)
  26. _TITLE "Wavy with Plasma trans by bplus, Press Spacebar for New Plasma Injection."
  27. DIM SHARED pR, pG, pB AS INTEGER
  28. DIM x, y, xball, yball AS INTEGER
  29. DIM current_phi, phiIndex, phi AS DOUBLE
  30. current_phi = 0
  31. cN = 1
  32. resetPlasma
  33.     CLS
  34.     _LIMIT 10
  35.     IF _KEYHIT = 32 THEN cN = 1: resetPlasma
  36.     current_phi = current_phi + PHISTEP
  37.     FOR x = 0 TO (W + RADIUS) STEP DISTANCE
  38.         FOR y = 0 TO (H + RADIUS) STEP DISTANCE
  39.             'COLOR _RGB(120, 80, 80)
  40.             'CIRCLE (x, y), RADIUS
  41.             phiIndex = ((x + y) MOD (2 * W)) / RADIUS
  42.             phi = phiIndex * PHIDELTA + current_phi
  43.             xball = COS(phi) * RADIUS + x
  44.             yball = SIN(phi) * RADIUS + y
  45.             changePlasma
  46.             'LINE (x, y)-(xball, yball)
  47.             fcirc2 xball, yball, SMALL_R
  48.         NEXT
  49.     NEXT
  50.     _DISPLAY
  51.  
  52. SUB changePlasma ()
  53. cN = cN + 1
  54. COLOR _RGB(127 + 127 * SIN(pR * cN), 127 + 127 * SIN(pG * cN), 127 + 127 * SIN(pB * cN))
  55.  
  56. SUB resetPlasma ()
  57. pR = RND ^ 2: pG = RND ^ 2: pB = RND ^ 2
  58.  
  59. '========================================== sqrSeg Method for filled circle
  60. SUB fcirc2 (xx%, yy%, r%)
  61. 'const sqr12! = .5^.5  'in main const section
  62. r2% = r% * r%
  63. sqr12r% = sqr12! * r%
  64. LINE (xx% - sqr12r%, yy% - sqr12r%)-(xx% + sqr12r%, yy% + sqr12r%), , BF
  65. FOR x% = 0 TO sqr12r%
  66.     y% = SQR(r2% - x% * x%)
  67.     LINE (xx% - x%, yy% + sqr12r%)-(xx% - x%, yy% + y%)
  68.     LINE (xx% - x%, yy% - sqr12r%)-(xx% - x%, yy% - y%)
  69.     LINE (xx% + x%, yy% + sqr12r%)-(xx% + x%, yy% + y%)
  70.     LINE (xx% + x%, yy% - sqr12r%)-(xx% + x%, yy% - y%)
  71. FOR x% = sqr12r% TO r%
  72.     y% = SQR(r2% - x% * x%)
  73.     LINE (xx% - x%, yy% + y%)-(xx% - x%, yy% - y%)
  74.     LINE (xx% + x%, yy% + y%)-(xx% + x%, yy% - y%)
  75.  
  76. SUB fcirc (xx%, yy%, r%)
  77. r2% = r% * r%
  78. FOR x% = 0 TO r%
  79.     y% = INT(SQR(r2% - x% * x%))
  80.     LINE (xx% - x%, yy% + y%)-(xx% - x%, yy% - y%)
  81.     LINE (xx% + x%, yy% + y%)-(xx% + x%, yy% - y%)
  82.  
  83.  

Oh, I guess I was experimenting with circle drawing here too.
* Wavy with Plasma 2.bas (Filesize: 2.71 KB, Downloads: 431)
« Last Edit: July 21, 2017, 11:30:54 pm by bplus »

Offline Calloway

  • Newbie
  • Posts: 18
  • I still have Laser Disc...
    • Calloway Sutton
Re: Plasma Waves
« Reply #1 on: July 21, 2017, 11:57:29 pm »

--snip--

This is a good way to say eff you to your epileptic friends (is cursing allowed on this forum?)
« Last Edit: July 22, 2017, 04:00:05 am by Calloway »

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: Plasma Waves
« Reply #2 on: July 22, 2017, 03:57:32 am »
Hi, it looks nice. The better effect is achieved by deleting CLS after WHILE 1 and inserting CLS after the _DISPLAY command.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Plasma Waves
« Reply #3 on: July 22, 2017, 12:57:56 pm »
Hi, it looks nice. The better effect is achieved by deleting CLS after WHILE 1 and inserting CLS after the _DISPLAY command.

Well without any winks, I can't tell if you are pulling my leg or that there really is a difference?

In the loop you are executing the same sequence of commands, so I don't see a difference on paper.

OK I try.

Oh wow! what a difference. Oops, I forgot to delete the first CLS; you can try that.

I think you are pulling my leg. :)

BTW I am using Walter's QB64 fork, if that makes any difference. I am newbie to QB64 and confuse it with FB which is what I started learning to compile SmallBASIC programs before Walter invited SmallBASIC forum people over to his to have and show file attachments and screen shots...

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
Re: Plasma Waves
« Reply #4 on: July 22, 2017, 01:43:39 pm »
Bplus: All clear. I did not know if the original intention was to redraw the screen from the beginning - clean or redraw it over the original background. Definitely without CLS it looks absolutely perfect. Good work, bplus!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Plasma Waves
« Reply #5 on: July 22, 2017, 03:41:57 pm »
Hey, it does work without CLS. I like that best!

Thanks!

Offline Calloway

  • Newbie
  • Posts: 18
  • I still have Laser Disc...
    • Calloway Sutton
Re: Plasma Waves
« Reply #6 on: July 22, 2017, 07:54:39 pm »
And since there any errors (at least I can't find any)[/size] in the program, you can do
Code: QB64: [Select]
to speed it up a bit

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Plasma Waves
« Reply #7 on: July 23, 2017, 03:38:33 am »
And since there any errors (at least I can't find any)[/size] in the program, you can do
Code: QB64: [Select]
to speed it up a bit

Thanks for tip!

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
Re: Plasma Waves
« Reply #8 on: July 23, 2017, 08:26:21 am »
nice!! :)
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 bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Plasma Waves
« Reply #9 on: July 23, 2017, 01:11:40 pm »
Hey Ashish!

I don't know if you know this but I am a fan. You and all the regulars from the [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there].

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
Re: Plasma Waves
« Reply #10 on: July 24, 2017, 04:47:33 am »
Hey Ashish!

I don't know if you know this but I am a fan. You and all the regulars from the [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there].

I'm glad to hear this... :)
if (Me.success) {Me.improve()} else {Me.tryAgain()}


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