Tristan said:
thank you for your help.
Unfortunately, I forgot to mention, that the independent strings can
overlap and that they fade out their color during the 5 seconds. So
they fade out and become bigger and can overlap at the same time.
I'm not sure how that makes a difference.
An
image is a rectangle that covers everything below it.
True, but you can make the background completely transparent.
Moreover the string that has the brighter color should be below the
ones that have darker colors.
You mean "below" in Z, I take it? Then you need to perform a depth sort
-- either once or at each animation step, depending on your exact
requirements. That part is not so difficult, really, but it does
contribute to the overall complexity of the problem.
There are a lot of details and competing factors. It may help if you
take a step back for a moment and look at the problem from a higher
level. Look into general performance principles, and then explore how
to apply them to your particular code. Here are a few general
principles to get you started:
(1) Avoid unnecessary work.
For instance, when you execute a fade from one color to another, don't
step through color gradations so fine that the human eye cannot discern
the difference. Also, perform complex calculations once for each set of
inputs and cache the results, and minimize the different sets of input
you need to worry about.
(2) Avoid unnecessary object creation.
Cache and reuse objects where possible. To make this efficient, control
the number of different objects you will need.
(3) Be conservative about method invocation.
Invoking methods is good and right, but does carry overhead. Design
your classes to use fewer invocations of more complex methods in
preferrence to more invocations of simple methods. You could hope that
a good hotspot VM would help in the latter case, but I'd recommend that
you lean the other way to begin with unless there is compelling reason
to do otherwise.
(4) Avoid floating-point arithmetic wherever possible.
Integer arithmetic is faster where suitable. Floating point is
absolutely necessary only where the magnitudes of the operands,
intermediate values, and results vary widely or are completely unknown.
(5) Use arrays instead of Collections.
If you don't need the extra features that are provided by the
Collections API then don't burden your code with the overhead.
That's just to get you started. Moreover, to know where it will be most
beneficial to optimize, you should profile the execution of your code.
It usually doesn't help to optimize code that is rarely executed or is
already fast enough.
John Bollinger
(e-mail address removed)