The best thing you can do is have code that creates the properly-colored sprite image according to f(t). The simplest way would be to have an alpha image that you apply to an image of the proper color to generate the new ball image. Be careful to do this properly, or it can negatively affect your game's performance...