Fade out an Image?

Can anyone point me to any declares / code / examples, of fading out an image?
I have a text area, in which I would like to have a picture which fades out upon clicking in the text area.

(OS X Mavericks app)

Thank you all in advance.

Try this
First make a property in the window called FadeColor and set it to 0 in the window’s open event. Then
put a timer in the window that has this action event:

dim p as picture
dim h,w,i as integer
Canvas1.width
Canvas1.height
p=newpicture(w,h,32)
p.graphics.foreColor=RGB(255, 255, 255)

If FadeColor<255 then
FadeColor+1
p.mask.graphics.foreColor=rgb(FadeColor,FadeColor,FadeColor)
p.mask.graphics.fillrect 0,0,w,h
p.graphics.drawpicture MyPicture,0,0
canvas1.graphics.drawpicture p,0,0

End If

Untested from memory but should do the trick.

Just enable the fade timer on lost/got focus

Thanks, but unfortunately - that gave me about 6 errors :frowning:

or you use an overlay window on top like our OverlayMBS class in MBS Overlay plugin.

I just got to my computer and will fix my mistakes…memory and no computer is a bad thing sometimes :slight_smile:

I noticed some of the code got clipped in my post?!? I will post a live demo for u to download

Fantastic - Thank You :slight_smile:

I have an example of this in one of my sample projects from my Sockets presentation at XDC. Go here and download the presentation files for All Things Sockets - Kimball Larsen. Open the .zip file, and navigate to Examples/UDPExample/UDPExampleClientOnly.xojo_binary_project. Open that project and run. You’ll see a friendly “Don’t Panic” fade in slowly on screen.

This example uses a label, and is fading in rather than out, but can be used just as easily with an image and fade the other direction.

The example is also cross platform and completely flicker-free on Windows.

Let me know if you have any questions.

Kimball,
Thanks - I will take a look :slight_smile:

Here you go…

http://www.xojodevspot.com/demos/picturefade.zip

To make the fade happen faster increase the “1” in

Fadecolor = fadecolor + 1

Making 5 for example will make the fade happen 5 times faster… If you add a when

If fadecolor >= 255 to set the timer.mode to 0 it will stop the fading Once it has been completely faded from view :slight_smile: hope it helps

[quote=85158:@Kimball Larsen]I have an example of this in one of my sample projects from my Sockets presentation at XDC. Go here and download the presentation files for All Things Sockets - Kimball Larsen. Open the .zip file, and navigate to Examples/UDPExample/UDPExampleClientOnly.xojo_binary_project. Open that project and run. You’ll see a friendly “Don’t Panic” fade in slowly on screen.

This example uses a label, and is fading in rather than out, but can be used just as easily with an image and fade the other direction.

The example is also cross platform and completely flicker-free on Windows.

Let me know if you have any questions.[/quote]

May I share your link in references and resources at xojodevspot.com for other developers? :slight_smile:

Thank you both - I will take a look when I get home.

Matthew:

Arghhhhhh!
I can’t believe I am so dumb that I can’t even get your project to work on a MouseUp event :frowning:

I set your timer to OFF in the inspector, then added a mouse up event for Window1, which sets

Timer2.mode =Timer2.ModeMultiple

When I run it and click on the window - nothing happens???

weep weep.

Did you put “Return True” in the MouseDown Event? If not, mouseup never happens :-p

You’re not dumb!

You could’ve also put

Timer2.Mode = 2 :slight_smile:

Haha just for an explanation if I put timer1 no event handlers appear…its a bug in the IDE…so I was forced to use timer2 :-p

Ahhh - I also renamed the Timer to Timer 1

I will now try again.

IT WORKED - Yippeeeee
I never knew I had to return true in the mousedown, in order to make the mouse up work :slight_smile:

I also never knew that you have to name Timers starting from number 2??

Thank you so much !

Normally you don’t have to name the timer timer2…its a bug that appeared in the newest ide :slight_smile: if you need anything else…glad to help.

You may regret saying that ! :slight_smile:

I never regret helping… sometimes in doing so I gain knowledge myself. … If at first I don’t know how to do something…I always find a way… There is no such thing as impossible, besides impossibility :slight_smile: Either way its good developer relations. Even when I’m extremely busy I always find time to help… or at least get someone pointed in the right direction. If you’re not using time, its wasting :slight_smile:

No regrets… life’s too short.

Btw using a similar method as fading out the image you can fade-in as well (just start with the faded image by setting fadecolor to 255 and decrease the value instead of increasing it…stopping at 0 of course).