Hi,

We needed to "invert" the colour, so developed the function ...

function InvertColor( aColor : TColor) : TColor;
var
 r,g,b : integer;
begin
 r := (Color and $ff);
 g := (Color and $ff00) shr 8;
 b := (Color and $ff0000) shr 16;
 //
 // save as RGB (with inverted values)
 result := RGB( (255-r), (255-b), (255-g)) ;
end;

While this does directly not solve your problem, the process of swapping/selecting the various RGB values from your two given colours should provide a 'different' colour.

One possible  (NB  not checked !!!) ....

function ThirdColor( C1,C2 : TColor) : TColor;
var
 r1,g1,b1 : integer;
 r2,g2,b2 : integer;
begin
 r1 := (C1 and $ff);
 g1 := (C1 and $ff00) shr 8;
 b1 := (C1 and $ff0000) shr 16;
 //
 r2 := (C2 and $ff);
 g2 := (C2 and $ff00) shr 8;
 b2 := (C2 and $ff0000) shr 16;
 //
 // save as RGB (swap r1 & g2 and average of B values)
 result := RGB( g2, r1, (b1+b2)/2) ;
end;

Regards,
Brian
--------------------------------------------------
From: "Stephen Posey" <[email protected]>
Sent: Monday, June 07, 2010 1:26 AM
To: "Delphi-Talk Discussion List" <[email protected]>
Subject: Re: Color?

I'm guessing from the nature of your question that you probably don't just want them not equal, you want them sufficiently different to make them visually distinct.

So, I'd suggest trying something like taking the average of the separate Red, Green, and Blue components of C1 and C2 and using those to construct a third color.

Unless C1 and C2 are already close, that should give you a C3 well distinct from C1 and C2.

Can't promise how ATTRACTIVE it will be though ;-)

Stephen Posey
[email protected]



-----Original Message-----
From: -K2RFP- <[email protected]>
Sent: Jun 5, 2010 1:05 PM
To: [email protected]
Subject: Color?

On drawing on an image I have two Brush colors, C1 and C2.
How do I choose a third brush color C3 such that
(C3<>C1) and (C3<>C2) and C3 is a valid Brush color?
__________________________________________________
Delphi-Talk mailing list -> [email protected]
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk

__________________________________________________
Delphi-Talk mailing list -> [email protected]
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk




No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.829 / Virus Database: 271.1.1/2932 - Release Date: 06/12/10 04:35:00

__________________________________________________
Delphi-Talk mailing list -> [email protected]
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk

Reply via email to