Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

TColor almost = to TColor?

Posted on 1999-10-17
4
Medium Priority
?
231 Views
Last Modified: 2010-04-04
Based on the help in
http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=10220366 

I now have a average color (Colora) and inverted color (Colori). however; if the Colors are near grey then Colora and Colori are almost =. If I choose to use the Colori, then it will look identical to the Colora.

I want to be able to tell when Colora and Colori are visually close to each other and choose another color say white or Black.

Does anyone have a code segment or function that will tell me if the colors are close visually?

John
0
Comment
Question by:zitt
[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
  • Learn & ask questions
4 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 480 total points
ID: 2134275
The colors will be visually close together when the vector in the 3d color space the TColor represents is short.

Function ColorCloseness(c1, c2 : TColor) : Double;

  Function B(C:TColor):Byte;
  begin
    Result := (C SHR 16) AND $ff;
  end;

  Function G(C:TColor):Byte;
  begin
    Result := (C SHR 8) AND $ff;
  end;

  Function R(C:TColor):Byte;
  begin
    Result := C AND $ff;
  end;

begin
  Result := sqrt(sqr(R(C1)-R(C2)) + sqr(G(C1)-G(C2)) + SQR(B(C1)-B(C2)));
end;


A value of 10 (or so) or less from this function would indicate the colours are very close. Obviously you should experiment to arrive at an appropriate threshold for youy application.

Cheers,

Raymond.
0
 
LVL 15

Expert Comment

by:simonet
ID: 2134310
Following...®
0
 

Author Comment

by:zitt
ID: 2134676
Raymond,
Thanks... I should have thought of this simple solution being an engineer... but I never thought of colors as modelled in 3D space.
John
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6842284
This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  If you are an EE Pro user, you can also choose Power Search to find all your open questions.

This is the Community Support link, if help is needed, along with the link to All Topics which reflects many TAs recently added.

http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
http://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thank you,
Moondancer
Moderator @ Experts Exchange
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question