diff options
author | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2011-12-08 14:00:50 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2011-12-08 14:00:50 +0200 |
commit | 667a2ccc92749e61fe2ca2a5176734467978d548 (patch) | |
tree | 36a9b67d7e635bd0aea9d12fa330a03ea79c3c01 /src/corelib | |
parent | c94a76c1b4afacfee8fbed721790f1e6cfd351ec (diff) | |
download | fpGUI-667a2ccc92749e61fe2ca2a5176734467978d548.tar.xz |
New functions to return darker or lighter variations of a color.
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/fpg_base.pas | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/corelib/fpg_base.pas b/src/corelib/fpg_base.pas index 196b820c..ddeaa227 100644 --- a/src/corelib/fpg_base.pas +++ b/src/corelib/fpg_base.pas @@ -743,6 +743,8 @@ function fpgGetBlue(const AColor: TfpgColor): word; function fpgGetAlpha(const AColor: TfpgColor): word; function fpgGetAvgColor(const AColor1, AColor2: TfpgColor): TfpgColor; function fpgColor(const ARed, AGreen, ABlue: byte): TfpgColor; +function fpgDarker(const AColor: TfpgColor; APercent: Byte = 50): TfpgColor; +function fpgLighter(const AColor: TfpgColor; APercent: Byte = 50): TfpgColor; { Points } @@ -1036,6 +1038,32 @@ begin Result := ABlue or (AGreen shl 8) or (ARed shl 16); end; +function fpgDarker(const AColor: TfpgColor; APercent: Byte): TfpgColor; +var + lColor: TFPColor; +begin + lColor.Red := fpgGetRed(AColor); + lColor.Green := fpgGetGreen(AColor); + lColor.Blue := fpgGetBlue(AColor); + lColor.Red := Round(lColor.Red*APercent/100); + lColor.Green := Round(lColor.Green*APercent/100); + lColor.Blue := Round(lColor.Blue*APercent/100); + Result := FPColorTofpgColor(lColor); +end; + +function fpgLighter(const AColor: TfpgColor; APercent: Byte): TfpgColor; +var + lColor: TFPColor; +begin + lColor.Red := fpgGetRed(AColor); + lColor.Green := fpgGetGreen(AColor); + lColor.Blue := fpgGetBlue(AColor); + lColor.Red := Round((lColor.Red*APercent/100) + (255 - APercent/100*255)); + lColor.Green := Round((lColor.Green*APercent/100) + (255 - APercent/100*255)); + lColor.Blue := Round((lColor.Blue*APercent/100) + (255 - APercent/100*255)); + Result := FPColorTofpgColor(lColor); +end; + function PtInRect(const ARect: TfpgRect; const APoint: TPoint): Boolean; begin Result := (APoint.x >= ARect.Left) and |