Is it possible to draw text on a Graphics object that inverts what it's drawn on?
Printable View
Is it possible to draw text on a Graphics object that inverts what it's drawn on?
Here's my idea:
1.Create a colour-inverted copy of the background. See my FastPix in the CodeBank for a super-quick method if you need it.
2. Draw the text to a GraphicsPath with AddString.
3. Set the graphics clip with Graphics.SetClip(graphicspath)
4. (optional) If you want outline text, use GraphicsPath.Widen with a small pen.
5. Paint the inverted image on top of the background.
Like anything with clip regions or regions, that has the drawback that you won't get antialiased edges. If that matters, I'll need a bit more time to think of a way to solve it.
BB
Edit: later thought. If you want antialiased edges, it might work to reset the Clip, then draw the path again over the edges of the inverted part. Use Graphics.DrawPath + SmoothingMode.HighQuality, plus a pen in a neutral or partly transparent colour.
:) That's exactly what I did the first time, but for anti-aliasing I used a TextureBrush. I want to know if there's something like the VB6 XOR drawing mode that I hear about a lot on Google.