Author Topic: CircleFill and EllipseFill not working as expected with alpha  (Read 5729 times)

0 Members and 1 Guest are viewing this topic.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
CircleFill and EllipseFill not working as expected with alpha
« on: September 03, 2020, 03:43:26 pm »
Ok so I am attempting to create a reverse vignette  to give the illusion of things farther away becoming darker. And while using good ole CIRCLE works fairly well it of course generates the artifacts that makes it undesirable.  So I was going to try and use EllipseFill, since I am working in 640x480, but the results it is generating are quite frankly BAD. I either get a totally black ellipse or this god awful grey mess. It seems totally incapable of producing a smooth gradient that darkens as it gets smaller(further away). It seems to work with normal CIRCLE but with that nice pattern that happens when you FOR, CIRCLE, NEXT its hard to tell. but its certainly not working at all with the Ellipsefill, I'm hoping its just something I am doing that is wrong and not a situation where the function is incapable of doing a simple effect. As it totally destroys the existing colors rather than just darkening them.

The effect I achieved in the corners looks pretty good, especially in the ceiling corners. So I want to say its possible, I might just not be going about it correctly.

I have tried several variants so far, this code is the last one I was playing with when I gave up and posted this topic. They all had a fairly similar failures.
I attached Images of the 3 main results I get, that horrible grey issue, the total black issue, and how using circle turns out.

Code: QB64: [Select]
  1. '3D'esk dungeon crawl screen setup test 8/3/2020
  2. 'inspired by games like: "Stonekeep", "Phantasy Star", "Eye of the Beholder", and
  3. '                        "Dungeon Master II:Legend of SkullKeep"
  4. 'Attempting to use MAPTRIANGLE to apply textures to dungeon walls, as done in QB45 via DirectQB's
  5. 'maptriangle function
  6.  
  7. SCREEN _NEWIMAGE(640, 480, 32)
  8. 'texture& = _LOADIMAGE("CaveWallTexture.jpg", 32)
  9. 'Temporary development texture set
  10. Wall& = _LOADIMAGE("CaveWallx256.bmp", 32)
  11. Floor& = _LOADIMAGE("CaveFloorx256.bmp", 32)
  12. Ceiling& = _LOADIMAGE("CaveCeilingx256.bmp", 32)
  13.  
  14. '_MAPTRIANGLE (0, 0)-(320, 0)-(320, 240), texture& TO(0, 0)-(320, 100)-(320, 380), _DISPLAY
  15. '_MAPTRIANGLE (0, 0)-(0, 480)-(320, 240), texture& TO(0, 0)-(0, 480)-(320, 380), _DISPLAY
  16.  
  17. 'Left 0-10'
  18. _MAPTRIANGLE (0, 0)-(255, 0)-(255, 255), Wall& TO(0, 0)-(100, 60)-(100, 420), _DISPLAY
  19. _MAPTRIANGLE (0, 0)-(0, 255)-(255, 255), Wall& TO(0, 0)-(0, 480)-(100, 420), _DISPLAY
  20. 'left 10-20'
  21. _MAPTRIANGLE (0, 0)-(255, 0)-(255, 255), Wall& TO(100, 60)-(200, 120)-(200, 360), _DISPLAY
  22. _MAPTRIANGLE (0, 0)-(0, 255)-(255, 255), Wall& TO(100, 60)-(100, 420)-(200, 360), _DISPLAY
  23. 'left 20-30'
  24. _MAPTRIANGLE (0, 0)-(255, 0)-(255, 255), Wall& TO(200, 120)-(300, 180)-(300, 300), _DISPLAY
  25. _MAPTRIANGLE (0, 0)-(0, 255)-(255, 255), Wall& TO(200, 120)-(200, 360)-(300, 300), _DISPLAY
  26.  
  27. 'right 0-10'
  28. _MAPTRIANGLE (255, 0)-(0, 0)-(255, 255), Wall& TO(640, 0)-(540, 60)-(540, 420), _DISPLAY
  29. _MAPTRIANGLE (0, 255)-(0, 0)-(255, 255), Wall& TO(640, 0)-(640, 480)-(540, 420), _DISPLAY
  30. 'right 10-20'
  31. _MAPTRIANGLE (255, 0)-(0, 0)-(255, 255), Wall& TO(540, 60)-(440, 120)-(440, 360), _DISPLAY
  32. _MAPTRIANGLE (0, 255)-(0, 0)-(255, 255), Wall& TO(540, 60)-(540, 420)-(440, 360), _DISPLAY
  33. 'Right 20-30'
  34. _MAPTRIANGLE (255, 0)-(0, 0)-(255, 255), Wall& TO(440, 120)-(340, 180)-(340, 300), _DISPLAY
  35. _MAPTRIANGLE (0, 255)-(0, 0)-(255, 255), Wall& TO(440, 120)-(440, 360)-(340, 300), _DISPLAY
  36.  
  37. 'floor 0-10'
  38. _MAPTRIANGLE (0, 0)-(255, 0)-(255, 255), Floor& TO(0, 480)-(100, 420)-(540, 420), _DISPLAY
  39. _MAPTRIANGLE (0, 0)-(0, 255)-(255, 255), Floor& TO(0, 480)-(640, 480)-(540, 420), _DISPLAY
  40. 'floor 10-20'
  41. _MAPTRIANGLE (0, 0)-(255, 0)-(255, 255), Floor& TO(100, 420)-(200, 360)-(440, 360), _DISPLAY
  42. _MAPTRIANGLE (0, 0)-(0, 255)-(255, 255), Floor& TO(100, 420)-(540, 420)-(440, 360), _DISPLAY
  43. 'floor 20-30'
  44. _MAPTRIANGLE (0, 0)-(255, 0)-(255, 255), Floor& TO(200, 360)-(300, 300)-(340, 300), _DISPLAY
  45. _MAPTRIANGLE (0, 0)-(0, 255)-(255, 255), Floor& TO(200, 360)-(440, 360)-(340, 300), _DISPLAY
  46.  
  47. 'Ceiling 0-10'
  48. _MAPTRIANGLE (0, 0)-(255, 0)-(255, 255), Ceiling& TO(0, 0)-(100, 60)-(540, 60), _DISPLAY
  49. _MAPTRIANGLE (0, 0)-(0, 255)-(255, 255), Ceiling& TO(0, 0)-(640, 0)-(540, 60), _DISPLAY
  50. 'Ceiling 10-20'
  51. _MAPTRIANGLE (0, 0)-(255, 0)-(255, 255), Ceiling& TO(100, 60)-(200, 120)-(440, 120), _DISPLAY
  52. _MAPTRIANGLE (0, 0)-(0, 255)-(255, 255), Ceiling& TO(100, 60)-(540, 60)-(440, 120), _DISPLAY
  53. 'Ceiling 20'-30'
  54. _MAPTRIANGLE (0, 0)-(255, 0)-(255, 255), Ceiling& TO(200, 120)-(300, 180)-(340, 180), _DISPLAY
  55. _MAPTRIANGLE (0, 0)-(0, 255)-(255, 255), Ceiling& TO(200, 120)-(440, 120)-(340, 180), _DISPLAY
  56.  
  57.  
  58. 'darken corners(some artifacting remains in very corner with lighter textures)
  59. 'bottom left
  60. FOR i%% = 0 TO 20
  61.  LINE (0 + i%%, 480)-(300 + i%%, 300), _RGBA32(0, 0, 0, 120 - i%% * 6)
  62.  LINE (0, 480 - i%%)-(300, 300 - i%%), _RGBA32(0, 0, 0, 120 - i%% * 6)
  63. NEXT i%%
  64. 'bottom right
  65. FOR i%% = 0 TO 20
  66.  LINE (640 - i%%, 480)-(340 - i%%, 300), _RGBA32(0, 0, 0, 120 - i%% * 6)
  67.  LINE (640, 480 - i%%)-(340, 300 - i%%), _RGBA32(0, 0, 0, 120 - i%% * 6)
  68. NEXT i%%
  69. 'Top Left
  70. FOR i%% = 0 TO 24
  71.  LINE (0 + i%%, 0)-(300 + i%%, 180), _RGBA32(0, 0, 0, 160 - i%% * 6)
  72.  LINE (0, 0 + i%%)-(300, 180 + i%%), _RGBA32(0, 0, 0, 160 - i%% * 6)
  73. NEXT i%%
  74. 'top right
  75. FOR i%% = 0 TO 24
  76.  LINE (640 - i%%, 0)-(340 - i%%, 180), _RGBA32(0, 0, 0, 160 - i%% * 6)
  77.  LINE (640, 0 + i%%)-(340, 180 + i%%), _RGBA32(0, 0, 0, 160 - i%% * 6)
  78. NEXT i%%
  79. 'end of hall
  80. FOR i%% = 0 TO 12
  81.  LINE (300 - i%%, 180 - i%%)-(340 + i%%, 300 + i%%), _RGBA32(0, 0, 0, 160 - i%% * 8), B
  82. NEXT i%%
  83.  
  84. 'reverse vignette (darkens toward center of screen to simulate depth and light loss)
  85. FOR i% = 0 TO 320
  86.  'CIRCLE (320, 240), i%, _RGBA32(0, 0, 0, 256 - i% * .75), , , 3 / 4
  87.  EllipseFill 320, 240, 320 - i%, 240 - i% * .75, _RGBA32(0, 0, 0, 2)
  88. NEXT i%
  89.  
  90.  
  91. SUB EllipseFill (CX AS INTEGER, CY AS INTEGER, a AS INTEGER, b AS INTEGER, C AS _UNSIGNED LONG)
  92.  ' CX = center x coordinate
  93.  ' CY = center y coordinate
  94.  '  a = semimajor axis
  95.  '  b = semiminor axis
  96.  '  C = fill color
  97.  IF a = 0 OR b = 0 THEN EXIT SUB
  98.  w2 = a * a
  99.  h2 = b * b
  100.  h2w2 = h2 * w2
  101.  LINE (CX - a, CY)-(CX + a, CY), C, BF
  102.  DO WHILE y < b
  103.   y = y + 1
  104.   x = SQR((h2w2 - y * y * w2) \ h2)
  105.   LINE (CX - x, CY + y)-(CX + x, CY + y), C, BF
  106.   LINE (CX - x, CY - y)-(CX + x, CY - y), C, BF
  107.  
Granted after becoming radioactive I only have a half-life!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: CircleFill and EllipseFill not working as expected with alpha
« Reply #1 on: September 03, 2020, 04:00:02 pm »
@Cobalt

Try stepping through the "radius" faster. If you step 320 times 2 you are so far past alpha 255 you are opaque 2X's over! Good ole circle doesn't overlap itself over and over and aspect is calculated different than for ellipse.

Fill Ellipse is doing great, no  lines overlap that I can tell.

Here is step 2 through radius:
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(640, 480, 32)
  2.  
  3. COLOR , &HFFFFFFFF
  4.  
  5. 'reverse vignette (darkens toward center of screen to simulate depth and light loss)
  6. FOR i% = 0 TO 320 STEP 2
  7.     'CIRCLE (320, 240), i%, _RGBA32(0, 0, 0, 256 - i% * .75), , , 3 / 4
  8.     EllipseFill 320, 240, 320 - i%, 240 - i% * .75, _RGBA32(0, 0, 0, 2)
  9. NEXT i%
  10.  
  11.  
  12. SUB EllipseFill (CX AS INTEGER, CY AS INTEGER, a AS INTEGER, b AS INTEGER, C AS _UNSIGNED LONG)
  13.     ' CX = center x coordinate
  14.     ' CY = center y coordinate
  15.     '  a = semimajor axis
  16.     '  b = semiminor axis
  17.     '  C = fill color
  18.     IF a = 0 OR b = 0 THEN EXIT SUB
  19.     DIM h2 AS _INTEGER64
  20.     DIM w2 AS _INTEGER64
  21.     DIM h2w2 AS _INTEGER64
  22.     DIM x AS INTEGER
  23.     DIM y AS INTEGER
  24.     w2 = a * a
  25.     h2 = b * b
  26.     h2w2 = h2 * w2
  27.     LINE (CX - a, CY)-(CX + a, CY), C, BF
  28.     DO WHILE y < b
  29.         y = y + 1
  30.         x = SQR((h2w2 - y * y * w2) \ h2)
  31.         LINE (CX - x, CY + y)-(CX + x, CY + y), C, BF
  32.         LINE (CX - x, CY - y)-(CX + x, CY - y), C, BF
  33.     LOOP
  34.  
  35.  


« Last Edit: September 03, 2020, 04:05:47 pm by bplus »

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: CircleFill and EllipseFill not working as expected with alpha
« Reply #2 on: September 03, 2020, 04:45:42 pm »
@Cobalt

Try stepping through the "radius" faster. If you step 320 times 2 you are so far past alpha 255 you are opaque 2X's over! Good ole circle doesn't overlap itself over and over and aspect is calculated different than for ellipse.

thats why I was using such a small ALPHA value so the outer rings have less effect than the inner ones(eventually it would be solid black, Black is what I am expecting by the time the ellipse get close to the center due to the overlap effect). But why is everything turning grey?

it is still destroying the colors, turning everything grey.
Unless there is something I am missing?

If you look in the corners, you can see where I used LINE to add some darkening for 'shadows'(which is simply _RGBA32(0,0,0,#)) and it  didn't turn everything grey so why is ellipse fill turning all the texture colors grey instead of just darkening them?

Not sure If I can just create a layer using your example there then PUTIMAGE that gradient layer over the screen to achieve the effect, though I will look into it, But I would still like to just darken the image using ellipsefill.
Granted after becoming radioactive I only have a half-life!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: CircleFill and EllipseFill not working as expected with alpha
« Reply #3 on: September 03, 2020, 06:59:15 pm »
Just out of curiosity why aren't you using rectangles?

It's the corners that get darker faster than circle or ellipse in center.

I think color is naturally lost when you layer over with black. Can't really enjoy paintings with sunglasses on.

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(640, 480, 32)
  2.  
  3. COLOR , &HFFFFFFFF
  4.  
  5. 'reverse vignette (darkens toward center of screen to simulate depth and light loss)
  6. FOR i = 0 TO 320 STEP 3
  7.     LINE (0 + i, r * i)-STEP(_WIDTH - 2 * i, _HEIGHT - 2 * i * r), _RGBA32(0, 0, 0, 3), BF

  [ You are not allowed to view this attachment ]  



« Last Edit: September 03, 2020, 07:19:17 pm by bplus »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: CircleFill and EllipseFill not working as expected with alpha
« Reply #4 on: September 03, 2020, 07:06:54 pm »
I was just about to type that very question. Kind of like 'square peg in a round hole' problem... lol
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: CircleFill and EllipseFill not working as expected with alpha
« Reply #5 on: September 03, 2020, 09:43:12 pm »
Yeah looks OK, specially with Cobalt's corners already darkened. Here is alpha at 11:
  [ You are not allowed to view this attachment ]  
« Last Edit: September 03, 2020, 09:49:41 pm by bplus »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: CircleFill and EllipseFill not working as expected with alpha
« Reply #6 on: September 03, 2020, 10:12:44 pm »
A reverse circle might be nice to simulate a flashlight type effect.  Leave the circle area undarkened (or shade white/yellow for the light), and then darken more as you move from the light.  I’d think it’d have the potential for some nice effects.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: CircleFill and EllipseFill not working as expected with alpha(side-stepped)
« Reply #7 on: September 03, 2020, 10:40:55 pm »
Yeah, the rectangle method looks good, I guess I was thinking in photography terms, as a Vignette darkens the edges to hi-lite the center and was just thinking if I reversed that it would give me an effect I wanted. but the rectangle method does look really good. Thanks Bplus.

But Steve has a good idea\point too, If I wanted a light source to illuminate the wall somewhere down the hallway I might still need to be able to use CircleFill or Ellipsefill , and Might still need to know why its not changing the pixel values properly.

Granted after becoming radioactive I only have a half-life!

Offline Gets

  • Newbie
  • Posts: 28
    • View Profile
Re: CircleFill and EllipseFill not working as expected with alpha
« Reply #8 on: September 03, 2020, 11:01:53 pm »
thats why I was using such a small ALPHA value so the outer rings have less effect than the inner ones(eventually it would be solid black, Black is what I am expecting by the time the ellipse get close to the center due to the overlap effect). But why is everything turning grey?

it is still destroying the colors, turning everything grey.
Unless there is something I am missing?


The colors blend with each layer, so they become increasingly grey each time until you're just blending grey with grey.I'm not sure of why they specific shade of grey keeps coming up though, maybe it's just the limit of what can be reached with an alpha of 2.

Anyways, if you keep that in mind and limit how many layers you create as well as increase the opacity as you get closer to the center, you get a better effect. I made the ellipse larger for a smoother overall blend and added a light tint to it.

Loop code

Code: QB64: [Select]
  1. j = 0
  2. i% = 0
  3. WHILE i% < 640
  4.     'CIRCLE (320, 240), i%, _RGBA32(0, 0, 0, 256 - i% * .75), , , 3 / 4
  5.     EllipseFill 320, 240, 640 - i%, 480 - i% * .75, _RGBA32(50 - i% / 8, 25 - i% / 5, 15 - i% / 3, j * (.05 + (i% / 180)))
  6.     j = j + .2
  7.     i% = i% + j
  8.  

Not much rhyme or reason to the numbers. I just kept adjusting them until it looked decent. j adjusts the rate that it increments towards the centers and the alpha also increases as well; the tint begins with more red but that color also depletes the fastest.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: CircleFill and EllipseFill not working as expected with alpha
« Reply #9 on: September 03, 2020, 11:07:24 pm »
What the flashlight found:

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: CircleFill and EllipseFill not working as expected with alpha
« Reply #10 on: September 03, 2020, 11:22:23 pm »
Here's my go with EllipseFill shading and a moveable flashlight effect:

Code: [Select]
'3D'esk dungeon crawl screen setup test 8/3/2020
'inspired by games like: "Stonekeep", "Phantasy Star", "Eye of the Beholder", and
'                        "Dungeon Master II:Legend of SkullKeep"
'Attempting to use MAPTRIANGLE to apply textures to dungeon walls, as done in QB45 via DirectQB's
'maptriangle function

SCREEN _NEWIMAGE(640, 480, 32)
'texture& = _LOADIMAGE("CaveWallTexture.jpg", 32)
'Temporary development texture set
Wall& = _LOADIMAGE("CaveWallx256.bmp", 32)
Floor& = _LOADIMAGE("CaveFloorx256.bmp", 32)
Ceiling& = _LOADIMAGE("CaveCeilingx256.bmp", 32)

'_MAPTRIANGLE (0, 0)-(320, 0)-(320, 240), texture& TO(0, 0)-(320, 100)-(320, 380), _DISPLAY
'_MAPTRIANGLE (0, 0)-(0, 480)-(320, 240), texture& TO(0, 0)-(0, 480)-(320, 380), _DISPLAY

'Left 0-10'
_MAPTRIANGLE (0, 0)-(255, 0)-(255, 255), Wall& TO(0, 0)-(100, 60)-(100, 420), _DISPLAY
_MAPTRIANGLE (0, 0)-(0, 255)-(255, 255), Wall& TO(0, 0)-(0, 480)-(100, 420), _DISPLAY
'left 10-20'
_MAPTRIANGLE (0, 0)-(255, 0)-(255, 255), Wall& TO(100, 60)-(200, 120)-(200, 360), _DISPLAY
_MAPTRIANGLE (0, 0)-(0, 255)-(255, 255), Wall& TO(100, 60)-(100, 420)-(200, 360), _DISPLAY
'left 20-30'
_MAPTRIANGLE (0, 0)-(255, 0)-(255, 255), Wall& TO(200, 120)-(300, 180)-(300, 300), _DISPLAY
_MAPTRIANGLE (0, 0)-(0, 255)-(255, 255), Wall& TO(200, 120)-(200, 360)-(300, 300), _DISPLAY

'right 0-10'
_MAPTRIANGLE (255, 0)-(0, 0)-(255, 255), Wall& TO(640, 0)-(540, 60)-(540, 420), _DISPLAY
_MAPTRIANGLE (0, 255)-(0, 0)-(255, 255), Wall& TO(640, 0)-(640, 480)-(540, 420), _DISPLAY
'right 10-20'
_MAPTRIANGLE (255, 0)-(0, 0)-(255, 255), Wall& TO(540, 60)-(440, 120)-(440, 360), _DISPLAY
_MAPTRIANGLE (0, 255)-(0, 0)-(255, 255), Wall& TO(540, 60)-(540, 420)-(440, 360), _DISPLAY
'Right 20-30'
_MAPTRIANGLE (255, 0)-(0, 0)-(255, 255), Wall& TO(440, 120)-(340, 180)-(340, 300), _DISPLAY
_MAPTRIANGLE (0, 255)-(0, 0)-(255, 255), Wall& TO(440, 120)-(440, 360)-(340, 300), _DISPLAY

'floor 0-10'
_MAPTRIANGLE (0, 0)-(255, 0)-(255, 255), Floor& TO(0, 480)-(100, 420)-(540, 420), _DISPLAY
_MAPTRIANGLE (0, 0)-(0, 255)-(255, 255), Floor& TO(0, 480)-(640, 480)-(540, 420), _DISPLAY
'floor 10-20'
_MAPTRIANGLE (0, 0)-(255, 0)-(255, 255), Floor& TO(100, 420)-(200, 360)-(440, 360), _DISPLAY
_MAPTRIANGLE (0, 0)-(0, 255)-(255, 255), Floor& TO(100, 420)-(540, 420)-(440, 360), _DISPLAY
'floor 20-30'
_MAPTRIANGLE (0, 0)-(255, 0)-(255, 255), Floor& TO(200, 360)-(300, 300)-(340, 300), _DISPLAY
_MAPTRIANGLE (0, 0)-(0, 255)-(255, 255), Floor& TO(200, 360)-(440, 360)-(340, 300), _DISPLAY

'Ceiling 0-10'
_MAPTRIANGLE (0, 0)-(255, 0)-(255, 255), Ceiling& TO(0, 0)-(100, 60)-(540, 60), _DISPLAY
_MAPTRIANGLE (0, 0)-(0, 255)-(255, 255), Ceiling& TO(0, 0)-(640, 0)-(540, 60), _DISPLAY
'Ceiling 10-20'
_MAPTRIANGLE (0, 0)-(255, 0)-(255, 255), Ceiling& TO(100, 60)-(200, 120)-(440, 120), _DISPLAY
_MAPTRIANGLE (0, 0)-(0, 255)-(255, 255), Ceiling& TO(100, 60)-(540, 60)-(440, 120), _DISPLAY
'Ceiling 20'-30'
_MAPTRIANGLE (0, 0)-(255, 0)-(255, 255), Ceiling& TO(200, 120)-(300, 180)-(340, 180), _DISPLAY
_MAPTRIANGLE (0, 0)-(0, 255)-(255, 255), Ceiling& TO(200, 120)-(440, 120)-(340, 180), _DISPLAY


'darken corners(some artifacting remains in very corner with lighter textures)
'bottom left
FOR i%% = 0 TO 20
    LINE (0 + i%%, 480)-(300 + i%%, 300), _RGBA32(0, 0, 0, 120 - i%% * 6)
    LINE (0, 480 - i%%)-(300, 300 - i%%), _RGBA32(0, 0, 0, 120 - i%% * 6)
NEXT i%%
'bottom right
FOR i%% = 0 TO 20
    LINE (640 - i%%, 480)-(340 - i%%, 300), _RGBA32(0, 0, 0, 120 - i%% * 6)
    LINE (640, 480 - i%%)-(340, 300 - i%%), _RGBA32(0, 0, 0, 120 - i%% * 6)
NEXT i%%
'Top Left
FOR i%% = 0 TO 24
    LINE (0 + i%%, 0)-(300 + i%%, 180), _RGBA32(0, 0, 0, 160 - i%% * 6)
    LINE (0, 0 + i%%)-(300, 180 + i%%), _RGBA32(0, 0, 0, 160 - i%% * 6)
NEXT i%%
'top right
FOR i%% = 0 TO 24
    LINE (640 - i%%, 0)-(340 - i%%, 180), _RGBA32(0, 0, 0, 160 - i%% * 6)
    LINE (640, 0 + i%%)-(340, 180 + i%%), _RGBA32(0, 0, 0, 160 - i%% * 6)
NEXT i%%
'end of hall
FOR i%% = 0 TO 12
    LINE (300 - i%%, 180 - i%%)-(340 + i%%, 300 + i%%), _RGBA32(0, 0, 0, 160 - i%% * 8), B
NEXT i%%

'reverse vignette (darkens toward center of screen to simulate depth and light loss)
FOR i% = 0 TO 320 STEP 5
    EllipseFill 320, 240, 320 - i%, 240 - i% * .75, _RGBA32(0, 0, 0, 10)
NEXT i%

PCOPY 0, 1


x = 200: y = 200
DO

    PCOPY 1, 0
    k = _KEYHIT
    SELECT CASE k
        CASE ASC("A"), ASC("a"): x = x - 3
        CASE ASC("S"), ASC("s"): y = y + 3
        CASE ASC("D"), ASC("d"): x = x + 3
        CASE ASC("W"), ASC("w"): y = y - 3
    END SELECT
    IF x < 0 THEN x = 0
    IF y > _HEIGHT THEN y = _HEIGHT
    IF y < 0 THEN y = 0
    IF x > _WIDTH THEN x = _WIDTH
    FOR i% = 0 TO 100 STEP 5 'moveable flashlight
        EllipseFill x, y, 100 - i%, 100 - i%, _RGBA32(105, 105, 0, 10)
    NEXT i%
    _DISPLAY
LOOP UNTIL k = 27
SLEEP


SUB EllipseFill (CX AS INTEGER, CY AS INTEGER, a AS INTEGER, b AS INTEGER, C AS _UNSIGNED LONG)
    ' CX = center x coordinate
    ' CY = center y coordinate
    '  a = semimajor axis
    '  b = semiminor axis
    '  C = fill color
    IF a = 0 OR b = 0 THEN EXIT SUB
    DIM h2 AS _INTEGER64
    DIM w2 AS _INTEGER64
    DIM h2w2 AS _INTEGER64
    DIM x AS INTEGER
    DIM y AS INTEGER
    w2 = a * a
    h2 = b * b
    h2w2 = h2 * w2
    LINE (CX - a, CY)-(CX + a, CY), C, BF
    DO WHILE y < b
        y = y + 1
        x = SQR((h2w2 - y * y * w2) \ h2)
        LINE (CX - x, CY + y)-(CX + x, CY + y), C, BF
        LINE (CX - x, CY - y)-(CX + x, CY - y), C, BF
    LOOP
END SUB


Make certain to use the images from the original post, for everything to work and look properly.

Edit: Added a quick screenshot, but it really doesn't do the effects justice, as you're missing out on moving the light yourself.  Just copy the dang code and run it for yourself and enjoy the full effect.  :P
« Last Edit: September 03, 2020, 11:28:23 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: CircleFill and EllipseFill not working as expected with alpha
« Reply #11 on: September 04, 2020, 05:10:05 pm »
What the flashlight found:

Thats really cool Bplus! I might use that somewhere as a secret or something! :D
Granted after becoming radioactive I only have a half-life!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: CircleFill and EllipseFill not working as expected with alpha
« Reply #12 on: September 04, 2020, 05:15:31 pm »
Thats really cool Bplus! I might use that somewhere as a secret or something! :D

:) Glad you liked it! Whenever see dark black of night, I think of that.