Solved

# Keep same colors algorithm

Posted on 2004-10-11
156 Views
I have for my button a color Color1 ( ex: \$005200A4 ) . For border Color2 ( ex.\$0036006C) and Color3 ( ex: \$009428FF ).

The color2 is a dark Color1 and Color3 is the light Color1.

I wish to get instantly Color2/Color3 when change Color1 to have omolog dark/light color for the new Color1. Same darkness/lightness scale.

How to do that?
0
Question by:ginsonic
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2

LVL 7

Expert Comment

ID: 12278264
The lower the number the "darker" the color (I think).

\$52  \$00  \$A4  is color 1
\$36  \$00  \$6C  is color2 (darker, lower numbers)
-\$1C -\$00 -\$38  subtract from normal color to get darker ... lowest number should be \$00

\$94  \$28  \$FF  is color3 (lighter, higher numbers)
+\$42 +\$28 +\$5B  add to normal color to get lighter ... highest number should be \$FF

You do need to deal with each piece of the color separately, as shown.

Just a thought...
0

LVL 7

Accepted Solution

LRHGuy earned 500 total points
ID: 12278394
This seems to work for me. You might want to play with the values being added/subtracted to get a good contrast...

type
c1=record
case integer of
0:( p:array[0..3] of byte);
1:(l:longint)
end;

var
C,L,D:c1;
begin
{\$R-}
if result<orig then
result:=\$ff; {full bright}
{\$R+}
end;
begin
{\$R-}
if result>orig then
result:=\$00; {full dark}
{\$R+}
end;
begin
C.l:=aOrig;
// make lighter color
L.L:=C.L;
L.p[1]:=lighter(C.p[1],\$5B);
L.p[2]:=lighter(C.p[2],\$28);
L.p[3]:=lighter(C.p[3],\$42);
aLighter:=L.L;
// make darker color
D.L:=C.L;
D.p[1]:=darker(C.p[1],\$1c);
D.p[2]:=darker(C.p[2],\$1c);
D.p[3]:=darker(C.p[3],\$38);
end;

procedure TForm2.Button1Click(Sender: TObject);
var
C,L,D:tColor;
begin
self.color:=clYellow;
makecolors(Self.Color,L,D);
panel1.color:=L;
end;
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

### Suggested Solutions

Delphi 2 92
Convert GUI app into console app for Win32 Env 5 140
Problem working with dynamic array - help 2 49
Firemonkey how to swip panel with finger tap 1 42
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
###### Suggested Courses
Course of the Month2 days, 17 hours left to enroll