### Author Topic: Plasma Waves  (Read 5610 times)

0 Members and 1 Guest are viewing this topic.

#### 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
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.     _LIMIT 10
34.     IF _KEYHIT = 32 THEN cN = 1: resetPlasma
35.     current_phi = current_phi + PHISTEP
36.     FOR x = 0 TO (W + RADIUS) STEP DISTANCE
37.         FOR y = 0 TO (H + RADIUS) STEP DISTANCE
38.             'COLOR _RGB(120, 80, 80)
40.             phiIndex = ((x + y) MOD (2 * W)) / RADIUS
41.             phi = phiIndex * PHIDELTA + current_phi
42.             xball = COS(phi) * RADIUS + x
43.             yball = SIN(phi) * RADIUS + y
44.             changePlasma
45.             'LINE (x, y)-(xball, yball)
46.             fcirc2 xball, yball, SMALL_R
47.
48. SUB changePlasma ()
49. cN = cN + 1
50. COLOR _RGB(127 + 127 * SIN(pR * cN), 127 + 127 * SIN(pG * cN), 127 + 127 * SIN(pB * cN))
51.
52. SUB resetPlasma ()
53. pR = RND ^ 2: pG = RND ^ 2: pB = RND ^ 2
54.
55. '========================================== sqrSeg Method for filled circle
56. SUB fcirc2 (xx%, yy%, r%)
57. 'const sqr12! = .5^.5  'in main const section
58. r2% = r% * r%
59. sqr12r% = sqr12! * r%
60. LINE (xx% - sqr12r%, yy% - sqr12r%)-(xx% + sqr12r%, yy% + sqr12r%), , BF
61. FOR x% = 0 TO sqr12r%
62.     y% = SQR(r2% - x% * x%)
63.     LINE (xx% - x%, yy% + sqr12r%)-(xx% - x%, yy% + y%)
64.     LINE (xx% - x%, yy% - sqr12r%)-(xx% - x%, yy% - y%)
65.     LINE (xx% + x%, yy% + sqr12r%)-(xx% + x%, yy% + y%)
66.     LINE (xx% + x%, yy% - sqr12r%)-(xx% + x%, yy% - y%)
67. FOR x% = sqr12r% TO r%
68.     y% = SQR(r2% - x% * x%)
69.     LINE (xx% - x%, yy% + y%)-(xx% - x%, yy% - y%)
70.     LINE (xx% + x%, yy% + y%)-(xx% + x%, yy% - y%)
71.
72. SUB fcirc (xx%, yy%, r%)
73. r2% = r% * r%
74. FOR x% = 0 TO r%
75.     y% = INT(SQR(r2% - x% * x%))
76.     LINE (xx% - x%, yy% + y%)-(xx% - x%, yy% - y%)
77.     LINE (xx% + x%, yy% + y%)-(xx% + x%, yy% - y%)
78.
79.

Oh, I guess I was experimenting with circle drawing here too.
« Last Edit: July 21, 2017, 11:30:54 pm by bplus »

#### Calloway

• Newbie
• Posts: 18
• I still have Laser Disc...
##### 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 »

#### 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.

#### 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...

#### 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!

#### 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!

#### Calloway

• Newbie
• Posts: 18
• I still have Laser Disc...
##### 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

#### 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!

#### 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

#### 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].

#### 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