[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Making text fade away...

Posted on 1998-07-29
7
Medium Priority
?
257 Views
Last Modified: 2010-03-30
What is a good way to give the appearance that a String of text is fading away?  How can I do this?
0
Comment
Question by:bjg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 2

Expert Comment

by:shchuka
ID: 1229056
One way of going about it would be to draw the text on something (canvas or whatever) with different color starting with the inverse of the background and going to the background.  A number of colors you need to go through is determined by how fast you want the text to fade away.
0
 

Author Comment

by:bjg
ID: 1229057
How do I find the inverse of the background?
0
 

Author Comment

by:bjg
ID: 1229058
Could you provide a small example of how to do this?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:bjg
ID: 1229059
How can I make this dynamic according to what color the text is, and what color the background is?  I don't want to hardcode anything in terms of colors.  I want it to all be dynamic depending on the colors being used.  How can I do this?
0
 
LVL 2

Expert Comment

by:shchuka
ID: 1229060
The easy way to figure out the inverse of a color is the following:

break the color into RGB components, say (red, green, blue) contain the values.  Then the inverse of the color is simply (255-red, 255-green, 255-blue).

Start up from here.
0
 

Author Comment

by:bjg
ID: 1229061
I am not sure if understand what you are trying to do though...I think what I am trying to do is I want to fade the Color of the graphics so that it eventually is the same color as the background of the Canvas.  So how would you do this with what you proposed?  Could you provide an example?
0
 
LVL 16

Accepted Solution

by:
imladris earned 100 total points
ID: 1229062
OK, how about this:

You can get the foreground and background colours for any component, witht the getBackground and getForeground methods. Establish the total difference for each of the three colour components, i.e. if frg is a Color object representing the foreground colour and bkg for the bkg:

int reddif=frg.getRed()-bkg.getRed();

now reddif (and blue- and greendiff) represent the amounts you have to subtract from their foreground components to make them equal to the background ones. Now supposing you want to fade in 20 steps, for any step you would change the foreground colour to:

new Color(frg.getRed()-(reddif*i)/20,frg.getGreen()-(greendiff*i)/20,
        frg.getBlue()-(bluediff*i)/20);

and redraw the text. Simply redraw the text repeatedly in an animation loop.

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question