I would like to draw a progress indicator with a percentage in its center, but I would like the text to have a negative (contrast) background color .
Thus, the part of the text that is above the filled part of the ProgressBar will be white, and the part above the unfilled part will be white.
I could do it simply by "cheating"
- draw the black part of the text first.
- draw a stroke rectangle (it will cover the part that should be hidden)
- draw white text only along the stroke rectangle (crop it)
The performance effect when drawing text twice in this application is negligible, but I wonder if there is an easy way to do this in just two steps (for example, if the progress bar somehow inverts already drawn text) using blending .
source
share