Author Topic: Eye Candy  (Read 7309 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Eye Candy
« on: March 06, 2022, 10:03:07 pm »
Code: QB64: [Select]
  1. _Title "Sprezzo #2 Problem 2022-03-06"
  2. Const SQ = 700, SQd2 = SQ / 2
  3. Screen _NewImage(SQ, SQ, 32)
  4. _ScreenMove 300, 60
  5. Dim Shared As Single cN, pR, pG, pB
  6. Dim diag, pi2, i, a, di, r, s
  7. diag = SQd2 * Sqr(2)
  8. pi2 = _Pi(2)
  9.  
  10. Dim colr~&(-1000 To diag + 1000)
  11.     resetPlasma
  12.     For i = -1000 To diag + 1000
  13.         colr~&(i) = Plasma~&
  14.     Next
  15.     di = 1: s = 0
  16.     For a = 0 To pi2 Step pi2 / (16 * 360)
  17.         i = 50 * Sin(s) ' 2 * s or just s
  18.         For r = 0 To diag
  19.             PSet (SQd2 + r * Cos(a), SQd2 + r * Sin(a)), colr~&(r + i)
  20.         Next
  21.         's = s + _Pi(1 / 128)
  22.         s = s + pi2 / 180 ' for almost seamless connect  
  23.     Next
  24.     Sleep
  25.  
  26. Function Plasma~& ()
  27.     cN = cN + .5 'dim shared cN as _Integer64, pR as long, pG as long, pB as long
  28.     Plasma~& = _RGB32(127 + 127 * Sin(pR * cN), 127 + 127 * Sin(pG * cN), 127 + 127 * Sin(pB * cN))
  29.  
  30. Sub resetPlasma ()
  31.     pR = Rnd ^ 2: pG = Rnd ^ 2: pB = Rnd ^ 2
  32.  
  33.  
spectacular.PNG
Sp #2-1.PNG
* Sp #2-1.PNG (Filesize: 304.06 KB, Dimensions: 701x708, Views: 190)
sp 2 -2.PNG
* sp 2 -2.PNG (Filesize: 463.52 KB, Dimensions: 700x707, Views: 194)
sp2 -3.PNG
* sp2 -3.PNG (Filesize: 382.34 KB, Dimensions: 701x707, Views: 196)
« Last Edit: March 07, 2022, 01:02:03 pm by bplus »

Offline CharlieJV

  • Newbie
  • Posts: 89
    • View Profile
Re: Eye Candy
« Reply #1 on: March 06, 2022, 10:41:02 pm »
Oh man, that's good stuff.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Eye Candy
« Reply #2 on: March 07, 2022, 02:20:19 am »
My eyes! My eyes! I have lost the ability to blink! Oh the humanity!  lol
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Eye Candy
« Reply #3 on: March 07, 2022, 01:02:38 pm »
OP updated for more perfect seamless connection.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Eye Candy
« Reply #4 on: March 07, 2022, 05:18:55 pm »
My eyes! My eyes! I have lost the ability to blink! Oh the humanity!  lol

Me too, but thanks to Mark, I can now add "BLIND" to my list of tax deductions!

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Eye Candy
« Reply #5 on: March 07, 2022, 06:20:46 pm »
OP updated for more perfect seamless connection.

More perfect?  come on,  more seam less

Good one Pete!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Eye Candy
« Reply #6 on: March 08, 2022, 06:58:15 pm »
Growing slowly:
Code: QB64: [Select]
  1. _Title " Eye Candy #9A growing slowly" ' b+ 2022-03-08
  2. DefDbl A-Z
  3. Screen _NewImage(xmax, ymax, 32)
  4. xc = xmax / 2
  5. yc = ymax / 2
  6. diag = Sqr(xc * xc + yc * yc)
  7. p2 = _Pi * 2
  8. Dim colr(-100 To diag + 300) As _Unsigned Long
  9. Dim Shared cN, pR, pG, pB
  10.     resetPlasma
  11.     For i = -100 To diag + 300
  12.         colr(i) = Plasma~&
  13.     Next
  14.  
  15.     ro = 250: s = 0
  16.     While ro > -50 And _KeyDown(27) = 0
  17.         k$ = InKey$
  18.         If Len(k$) Then Exit While
  19.         For a = 0 To p2 Step p2 / (16 * 360)
  20.             i = 50 * Sin(s) ' 2 * s or just s
  21.             For r = 0 To diag
  22.                 PSet (xc + r * Cos(a), yc + r * Sin(a)), colr(r + i + ro)
  23.             Next
  24.             s = s + p2 / 180
  25.         Next
  26.         _Display
  27.         ro = ro - 10
  28.     Wend
  29.  
  30. Function Plasma~& ()
  31.     cN = cN + .2
  32.     Plasma~& = _RGB32(127 + 127 * Sin(pR * cN), 127 + 127 * Sin(pG * cN), 127 + 127 * Sin(pB * cN))
  33.  
  34. Sub resetPlasma ()
  35.     pR = Rnd ^ 2: pG = Rnd ^ 2: pB = Rnd ^ 2
  36.  
  37.  
  38.  

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Eye Candy
« Reply #7 on: March 08, 2022, 08:24:30 pm »
Woah!  Very nice, @bplus

- Dav

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Eye Candy
« Reply #8 on: March 08, 2022, 09:37:18 pm »
Yeah funny story I was trying to duplicate this background:
 
Problem.PNG

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Eye Candy
« Reply #9 on: March 08, 2022, 10:23:27 pm »
Strange pattern.  I thought it was an animated image at first.  Appears to move a little when I look at it.

- Dav

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Eye Candy
« Reply #10 on: March 08, 2022, 10:50:09 pm »
Ha ha, an animated un-animated png! Nice optical illusion.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Eye Candy
« Reply #11 on: March 09, 2022, 12:54:01 am »
Oh wow, _MapTriangle sure sped up the animation and look closer to original intended image!
Code: QB64: [Select]
  1. _Title " Eye Candy #9B Closer" ' b+ 2022-03-09
  2. DefDbl A-Z
  3. Screen _NewImage(xmax, ymax, 32)
  4. xc = xmax / 2
  5. yc = ymax / 2
  6. diag = Sqr(xc * xc + yc * yc)
  7. p2 = _Pi * 2
  8. Dim colr(-100 To diag + 1000) As _Unsigned Long
  9. Dim Shared cN, pR, pG, pB
  10.     resetPlasma
  11.     For i = -100 To diag + 1000
  12.         colr(i) = Plasma~&
  13.     Next
  14.  
  15.     ro = 950: s = 0
  16.     While ro > -50 And _KeyDown(27) = 0
  17.         k$ = InKey$
  18.         If Len(k$) Then Exit While
  19.         Cls
  20.         For a = 0 To p2 / 64 Step p2 / (16 * 360)
  21.             i = 50 * Sin(s) ' 2 * s or just s
  22.             For r = 0 To diag
  23.                 PSet (xc + r * Cos(a), yc + r * Sin(a)), colr(r + i + ro)
  24.             Next
  25.             s = s + p2 / 180
  26.         Next
  27.         sx1 = xc: sy1 = yc: sx2 = xc + diag * Cos(0): sy2 = yc + diag * Sin(0): sx3 = xc + diag * Cos(p2 / 64): sy3 = yc + diag * Sin(p2 / 64)
  28.         For a = p2 / 64 To p2 - p2 / 64 Step p2 / 64
  29.             dx1 = xc: dy1 = yc: dx2 = xc + diag * Cos(a): dy2 = yc + diag * Sin(a): dx3 = xc + diag * Cos(a + p2 / 64): dy3 = yc + diag * Sin(a + p2 / 64)
  30.             _MapTriangle (sx1, sy1)-(sx2, sy2)-(sx3, sy3), source& To(dx1, dy1)-(dx2, dy2)-(dx3, dy3), 0
  31.         Next
  32.         Line (0, 0)-(xc - 1.5 * yc, _Height), &HFF000000, BF
  33.         Line (xc + 1.5 * yc, 0)-(_Width, _Height), &HFF000000, BF
  34.         toggle = 1 - toggle
  35.         If toggle Then _Display
  36.         '_Limit 80
  37.         ro = ro - 1
  38.     Wend
  39.  
  40. Function Plasma~& ()
  41.     cN = cN + .2
  42.     Plasma~& = _RGB32(127 + 127 * Sin(pR * cN), 127 + 127 * Sin(pG * cN), 127 + 127 * Sin(pB * cN))
  43.  
  44. Sub resetPlasma ()
  45.     pR = Rnd ^ 2: pG = Rnd ^ 2: pB = Rnd ^ 2
  46.  
  47.  
  48.  
Eye Candy #9B Closer.PNG

 
Eye Candy #9B Closer Reverse.PNG


Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Eye Candy
« Reply #12 on: March 09, 2022, 11:04:41 am »
Yes, huge speed increase on my T430 laptop. Beautiful little program.

- Dav

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Eye Candy
« Reply #13 on: March 09, 2022, 12:04:01 pm »
If you want to see something weird, comment toggle lines and slow Limit way down.

?...  I have no idea!

Neither do I have any idea what causes the color crescents to suddenly reverse? Sometimes they point towards center other times they point outward (see the 2 snapshots).

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Eye Candy
« Reply #14 on: March 09, 2022, 06:57:12 pm »
Totally gnarly! Like it gives me some ideas. Peace!