Active Forums => QB64 Discussion => Topic started by: bplus on October 04, 2021, 10:16:51 am
Title: Looking for Way to Fade In (or Out) an Image
Post by: bplus on October 04, 2021, 10:16:51 am
This question came up last night with Dav's Pipe Connecting Puzzle:
Is there a way to fade an image in or out without having to resort to a pixel at a time with Point?
That would be so nice to use for ghostly faces and other Halloween tricks.
Title: Re: Looking for Way to Fade In (or Out) an Image
Post by: SMcNeill on October 04, 2021, 10:24:59 am
Cover it with an alpha colored box.
Image is from (100,100)-(200,200)
FOR I = 1 TO 10 LINE(100,100)-(200,200), _RGBA(0, 0, 0, 100), BF NEXT
Will fade to black over multiple passes.
Title: Re: Looking for Way to Fade In (or Out) an Image
Post by: SMcNeill on October 04, 2021, 10:30:27 am
Or pre-alpha your image to various levels and save an array of them. Then you can pick and choose which one you need for the current stage of the effect.
FOR I = 1 TO 10 CLS, RED PUTIMAGE (x, y), faded_image(i) SLEEP NEXT
^fresh red background with you putting 10 different alpha backgrounds over it one at a time.
Which might also be accomplished via SETALPHA.
https://www.qb64.org/wiki/SETALPHA
Title: Re: Looking for Way to Fade In (or Out) an Image
Post by: Cobalt on October 04, 2021, 12:37:47 pm
There is a routine in the wiki to do just that.... give me a second...
cant quite remember where it is in the wiki but here is the copy I've been using(how things fade in Dragon Warrior)
Title: Re: Looking for Way to Fade In (or Out) an Image
Post by: bplus on October 04, 2021, 12:43:06 pm
Thanks again Steve, _SetAlpha is probably the tool I had in mind.
I think I meant to say I wanted a transparent image laid over an background and gradually change from transparent to opaque.
Actually I started to consider random filling another image over a background image with Point at a low to middle transparency.
Oh Cobalt has posted, I will read next.
Title: Re: Looking for Way to Fade In (or Out) an Image
Post by: bplus on October 04, 2021, 12:45:52 pm
@Colbalt very interesting, thank you.
Title: Re: Looking for Way to Fade In (or Out) an Image
Post by: Cobalt on October 04, 2021, 04:09:47 pm
Your Welcome. I've found it to be useful. Layer(0) is basically _DISPLAY Adjusting the _DELAY can make it fade slower or faster was well as the STEP in the FOR. And of course you don't have to fade all the way in or out, you can have it stop where ever, but I've only ever used it for full in and outs.
Title: Re: Looking for Way to Fade In (or Out) an Image
Post by: Pete on October 04, 2021, 04:37:47 pm
Didn't we go over this in my Ghost Town game thread?