mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 16:09:31 +02:00
* Some utility routines
This commit is contained in:
parent
cf4fc4e385
commit
14d65ced2e
@ -31,10 +31,13 @@ Type
|
||||
PAlphaColor = ^TAlphaColor;
|
||||
TImageIndex = type Integer;
|
||||
|
||||
{ TColorRec }
|
||||
|
||||
TColorRec = record
|
||||
class var ColorToRGB: function (Color: TColor): Longint;
|
||||
class operator := (AColor : TColor): TColorRec; inline;
|
||||
class operator := (AColor : TColorRec): TColor; inline;
|
||||
function ToString : RTLString;
|
||||
const
|
||||
// 140 HTML colors.
|
||||
AliceBlue = TColor($FFF8F0);
|
||||
@ -239,6 +242,8 @@ Type
|
||||
TColors = TColorRec;
|
||||
|
||||
|
||||
{ TAlphaColors }
|
||||
|
||||
TAlphaColors = record
|
||||
const
|
||||
Null = TAlphaColor(0);
|
||||
@ -399,6 +404,7 @@ Type
|
||||
public
|
||||
constructor Create(const Color: TAlphaColor);
|
||||
class var ColorToRGB: function (Color: TAlphaColor): Longint;
|
||||
function ToString : RTLString;
|
||||
case Cardinal of
|
||||
0:
|
||||
(Color: TAlphaColor);
|
||||
@ -441,6 +447,12 @@ Type
|
||||
function ToAlphaColor: TAlphaColor;
|
||||
end;
|
||||
|
||||
{ TColorHelper }
|
||||
|
||||
TColorHelper = record helper for TColor
|
||||
Function ToString : RTLString;
|
||||
end;
|
||||
|
||||
|
||||
// copied from Lazutils version
|
||||
///////////////////////////////
|
||||
@ -957,11 +969,28 @@ begin
|
||||
result:=AColor.Color;
|
||||
end;
|
||||
|
||||
function TColorRec.ToString: RTLString;
|
||||
|
||||
var
|
||||
S : string;
|
||||
|
||||
begin
|
||||
if (Self.Color and $FF000000)=$FF then
|
||||
Result:='SYS '+HexStr(Self.Color and $00FFFFFF,6)
|
||||
else
|
||||
Result:='#'+HexStr(R,2)+HexStr(G,2)+HexStr(B,2)
|
||||
end;
|
||||
|
||||
constructor TAlphaColors.Create(const Color: TAlphaColor);
|
||||
begin
|
||||
Self := TAlphaColors(Color);
|
||||
end;
|
||||
|
||||
function TAlphaColors.ToString: RTLString;
|
||||
begin
|
||||
Result:='#'+HexStr(R,2)+HexStr(G,2)+HexStr(B,2)+HexStr(A,2)
|
||||
end;
|
||||
|
||||
|
||||
class function TAlphaColorF.Create(const R, G, B: Single; const A: Single = 1): TAlphaColorF; overload; static;
|
||||
|
||||
@ -1179,6 +1208,13 @@ begin
|
||||
CR.B:=CC(B);
|
||||
end;
|
||||
|
||||
{ TColorHelper }
|
||||
|
||||
function TColorHelper.ToString: RTLString;
|
||||
begin
|
||||
Result:=TColorRec(Self).ToString;
|
||||
end;
|
||||
|
||||
function DefaultColorToRGB(Color: TColor): Longint;
|
||||
begin
|
||||
Result:=Color;
|
||||
|
Loading…
Reference in New Issue
Block a user