makhaon / jcl Goto Github PK
View Code? Open in Web Editor NEWThis project forked from project-jedi/jcl
JEDI Code Library
Home Page: http://jcl.delphi-jedi.org
This project forked from project-jedi/jcl
JEDI Code Library
Home Page: http://jcl.delphi-jedi.org
type
.../...
type TColorSwap
private
public
class function ComplementaryColorFromHtmlColor(AHtmlColor: TColor; bSwapRedBlue: Boolean = False): TColor;
class function ComplementaryColor(AColor: TColor): TColor;
class function HighContrastColor(AColor: TColor): TColor;
class function SwappedRedGreenColor(AColor: TColor): TColor;
class function SwappedRedBlueColor(AColor: TColor): TColor;
end;
.../...
implementation
.../...
class function TColorSwap.ComplementaryColorFromHtmlColor(AHtmlColor: TColor; bSwapRedBlue: Boolean = False): TColor;
{$REGION 'Xls: Comments section'}
{
@param bSwapRedBlue: this parameter depends from your material context, and the purpose of this call:
Trick, to check first, which convention is used:
NB: if you use reference colors like clBlack, clLime, etc., from the LCL to find the complementary color of these, then leave bSwapRedBlue to false: the colors of the components are already natively - with respect to your machine's CPU - correctly managed. Or even better: use ComplementaryColor.
}
{$ENDREGION}
function SwapRedBlue(AColor: TColor): TColor;
{$REGION 'Xls: Comments section'}
{ See ComplementaryColorFromHtmlColor explanations. }
{$ENDREGION}
begin
Result:= RGBToColor(Graphics.Blue(AColor), Graphics.Green(AColor), Graphics.Red(AColor))
end;
begin
if bSwapRedBlue then
SwapRedBlue(AHtmlColor);
Result:= RGBToColor(255 - Graphics.Red(AHtmlColor), 255 - Graphics.Green(AHtmlColor), 255 - Graphics.Blue(AHtmlColor));
end;
class function TColorSwap.ComplementaryColor(AColor: TColor): TColor;
{$REGION 'Xls: Comments section'}
{ most efficient for complementary color. }
{$ENDREGION}
begin
Result := clWhite - ColorToRGB(AColor);
end;
class function TColorSwap.HighContrastColor(AColor: TColor): TColor;
{$REGION 'Xls: Comments section'}
{ The one that returns the color with the most contrast, in the middle of grey or pastel colors. }
{$ENDREGION}
begin
AColor := ColorToRGB(AColor);
if Red(AColor) + Green(AColor) + Blue(AColor) < 3*128 then
Result := clWhite
else
Result := clBlack;
end;
class function TColorSwap.SwappedRedGreenColor(AColor: TColor): TColor;
{$REGION 'Xls: Comments section'}
{ inspired from the "triadic color scheme": if color_base=RGB ==> sequencing triad_1=GBR, triad_2=BRG... }
{$ENDREGION}
begin
AColor := ColorToRGB(AColor);
Result := RGBToColor(Green(AColor), Red(AColor), Blue(AColor));
end;
class function TColorSwap.SwappedRedBlueColor(AColor: TColor): TColor;
{$REGION 'Xls: Comments section'}
{ inspired from the "triadic color scheme": if color_base=RGB ==> sequencing triad_1=GBR, triad_2=BRG... }
{$ENDREGION}
begin
AColor := ColorToRGB(AColor);
Result := RGBToColor(Blue(AColor), Green(AColor), Red(AColor));
end;
Best regards.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.