Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there a faster way to do this glow circle effect?
#4
Instead of drawing the circles over and over again I converted that into a light source image.

(you can remove that PCOPY 0, 1. That was another approach I was playing with, forgot to delete line)
Code: (Select All)

SCREEN _NEWIMAGE(1000, 700, 32)

'draw a background
FOR x = 0 TO _WIDTH STEP 25
    FOR y = 0 TO _HEIGHT STEP 25
        LINE (x, y)-STEP(25, 25), _RGBA(RND * 255, RND * 255, RND * 255, 150), BF
    NEXT
NEXT
PCOPY 0, 1

'draw a light source
light& = _NEWIMAGE(900, 900, 32)
_DEST light&
FOR x = 0 TO 450 STEP .333
    CIRCLE (449, 449), x, _RGBA(0, 0, 0, x / 1.9)
NEXT

_DEST 0

back& = _COPYIMAGE(_DISPLAY) 'image to use
work& = _COPYIMAGE(_DISPLAY) 'work screen
area& = _NEWIMAGE(600, 600, 32) 'faded area image

DO

    'get mouse input
    WHILE _MOUSEINPUT: WEND
    mx = _MOUSEX: my = _MOUSEY

    'point to the work screen
    _DEST work&

    'place background first
    _PUTIMAGE (0, 0), back&

    'place light source
    _PUTIMAGE (mx - 450, my - 450), light&

    'draw fadeout circle where mouse x/y is
    'FOR x = 0 TO 450 STEP .333
    '    CIRCLE (mx, my), x, _RGBA(0, 0, 0, x / 1.9)
    'NEXT

    'put changed part of work screen into area&
    _PUTIMAGE (0, 0), work&, area&, (mx - 300, my - 300)-(mx + 300, my + 300)

    'go back to main screen
    _DEST 0
    'clear it
    LINE (0, 0)-(_WIDTH, _HEIGHT), _RGB(0, 0, 0), BF

    'put faded area& onto screen
    _PUTIMAGE (mx - 300, my - 300), area&

    _DISPLAY
    _LIMIT 30

LOOP UNTIL INKEY$ <> ""
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
RE: Is there a faster way to do this glow circle effect? - by TerryRitchie - 06-16-2024, 02:26 PM



Users browsing this thread: 6 Guest(s)