Board index » delphi » Setting Exact Color of Mode [pmXOr] Set Pen

Setting Exact Color of Mode [pmXOr] Set Pen

I am drawing crosshair lines on a canvas using Pen.Mode := pmXor

How can I determine the exact color of the resultant line using the
background color and Pen color?
How can I set an exact resultant line color by calculating the Pen Color to
use?

Thanks in advance

Robin Twiggs

 

Re:Setting Exact Color of Mode [pmXOr] Set Pen


"Robin Twiggs" <rstwi...@global.co.za> skrev i en meddelelse
news:8mup1b$9611@bornews.borland.com...

Quote
> I am drawing crosshair lines on a canvas using Pen.Mode := pmXor
> How can I determine the exact color of the resultant line using the
> background color and Pen color?

Not sure about that.

Quote
> How can I set an exact resultant line color by calculating the Pen Color
to
> use?

If you want to use a specific colour such as Pen.Color := clRed then set
Pen.Mode := pmCopy.

Finn Tolderlund

Re:Setting Exact Color of Mode [pmXOr] Set Pen


Robin Twiggs schrieb:

Quote

> I am drawing crosshair lines on a canvas using Pen.Mode := pmXor

> How can I determine the exact color of the resultant line using the
> background color and Pen color?

Let "Color" be the background color:

  <line color> = ColorToRGB(Color) xor ColorToRGB(Pen.Color);

Quote
> How can I set an exact resultant line color by calculating the Pen Color to
> use?

By XORing both sides of the above equation with ColorToRGB(Color):

  Pen.Color := ColorToRGB(LineColor) xor ColorToRGB(Color);

Greetings, Robert
--
Robert Ro?mair

Re:Setting Exact Color of Mode [pmXOr] Set Pen


Thanks

using ColorToRGB(Color)xor ColorToRGB(Pen.Color) provided a reasonable
solution.

Robin Twiggs

Other Threads