xor-drawing

XOR Drawing in C#

前提是你 提交于 2020-01-03 03:38:08
问题 I am a trying to learn C# .Net. I had written small (hobby) Analog Clock application in VB sometime ago(edit: VB6, to be precise), and I thought I will rewrite in C#.NET, as part of my learning process. In the VB application, I drew the hands of the clock in XOR Drawmode, so that I have to move the second hand, I just had to redraw it in the previous position and then draw the current position - I need not refresh the whole Form. All I did was Me.DrawMode = vbNotXorPen and then Me.Line... on

How to draw a “not” colored text?

此生再无相见时 提交于 2019-12-06 05:34:17
问题 I'm looking for a way to draw text with inverted colors. For shapes, we have TPenMode that can be set to pmNot , but we can't do this for text. How can I do this instead? 回答1: This does it: procedure DrawTextNOT(const hDC: HDC; const Font: TFont; const Text: string; const X, Y: integer); begin with TBitmap.Create do try Canvas.Font.Assign(Font); with Canvas.TextExtent(Text) do SetSize(cx, cy); Canvas.Brush.Color := clBlack; Canvas.FillRect(Rect(0, 0, Width, Height)); Canvas.Font.Color :=