Author Topic: Swirling QB64 drainpipe. Another rotozoom effect.  (Read 4401 times)

0 Members and 1 Guest are viewing this topic.

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Swirling QB64 drainpipe. Another rotozoom effect.
« on: October 22, 2021, 09:58:47 am »
I keep playing around with the fascinating rotozoom.  Here's an effect I thought may be worth sharing.  Tried _SETALPHA on the _DISPLAY which seems to add a blur effect on the swirl.  Let it run a bit for interesting colors.

- Dav

Code: QB64: [Select]
  1.  
  2. SCREEN _NEWIMAGE(800, 640, 32)
  3.  
  4.     _SETALPHA RND * 254, , -11: s = RND * 125
  5.     _PUTIMAGE (RND * _WIDTH, RND * _HEIGHT)-STEP(s, s), -11
  6.     _SETALPHA RND * 255, 1 TO -1, _DISPLAY
  7.     RotoZoom3 _WIDTH / 2 + RND * 3, _HEIGHT / 2 + RND * 3, _DISPLAY, .88, .98, _D2R(a): a = a + 1
  8.     _LIMIT 25
  9.  
  10.  
  11. SUB RotoZoom3 (X AS LONG, Y AS LONG, Image AS LONG, xScale AS SINGLE, yScale AS SINGLE, radianRotation AS SINGLE)
  12.     DIM px(3) AS SINGLE: DIM py(3) AS SINGLE ' simple arrays for x, y to hold the 4 corners of image
  13.     DIM W&, H&, sinr!, cosr!, i&, x2&, y2& '   variables for image manipulation
  14.     W& = _WIDTH(Image&): H& = _HEIGHT(Image&)
  15.     px(0) = -W& / 2: py(0) = -H& / 2 'left top corner
  16.     px(1) = -W& / 2: py(1) = H& / 2 ' left bottom corner
  17.     px(2) = W& / 2: py(2) = H& / 2 '  right bottom
  18.     px(3) = W& / 2: py(3) = -H& / 2 ' right top
  19.     sinr! = SIN(-radianRotation): cosr! = COS(-radianRotation) ' rotation helpers
  20.     FOR i& = 0 TO 3 ' calc new point locations with rotation and zoom
  21.         x2& = xScale * (px(i&) * cosr! + sinr! * py(i&)) + X: y2& = yScale * (py(i&) * cosr! - px(i&) * sinr!) + Y
  22.         px(i&) = x2&: py(i&) = y2&
  23.     NEXT
  24.     _MAPTRIANGLE _SEAMLESS(0, 0)-(0, H& - 1)-(W& - 1, H& - 1), Image TO(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
  25.     _MAPTRIANGLE _SEAMLESS(0, 0)-(W& - 1, 0)-(W& - 1, H& - 1), Image TO(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
  26.  
  27.  

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Swirling QB64 drainpipe. Another rotozoom effect.
« Reply #1 on: October 22, 2021, 12:22:12 pm »
No! No! No! You need the FreeBASIC icon for that!

Well, help me out here. What part of the code picks up the QB64 icon from the title window?

Pete

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

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Swirling QB64 drainpipe. Another rotozoom effect.
« Reply #2 on: October 22, 2021, 12:48:07 pm »
I should not make a habit of posting code that uses it, but -11 is the image handle currently for the builtin icon.. I use at home frequently when experimentig, but its not a good idea to share code using i guess. Sorry about that.

- Dav

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Swirling QB64 drainpipe. Another rotozoom effect.
« Reply #3 on: October 22, 2021, 02:51:30 pm »
What's the number for the not-built in FB horse? That's what I want to see swirling around!

Thanks Dav, I had no idea about the -11 being reserved for the QB64 icon. That's useful!

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: Swirling QB64 drainpipe. Another rotozoom effect.
« Reply #4 on: October 22, 2021, 03:15:48 pm »
@Dav you should get even more effects by using the x and y scale independently.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Swirling QB64 drainpipe. Another rotozoom effect.
« Reply #5 on: October 22, 2021, 07:24:36 pm »
Just tried this demo... Cool... Not very accurate... but cool none the less.

Let me explain... For those of us that live "down under" the swirl (coriolis effect) is correct... Should this be moving in the opposite direction for those of us that live above the equator? Oh. I can be SO picky at times... (bplus... not a word... lol)
Logic is the beginning of wisdom.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Swirling QB64 drainpipe. Another rotozoom effect.
« Reply #6 on: October 22, 2021, 07:36:58 pm »
🙃
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Swirling QB64 drainpipe. Another rotozoom effect.
« Reply #7 on: October 23, 2021, 03:05:28 am »
Oh. Ha Ha... Good one, Pete.
Logic is the beginning of wisdom.