| 1 | {=== Color definitions ===}
|
|---|
| 2 |
|
|---|
| 3 | {$IFDEF INCLUDE_INTERFACE}
|
|---|
| 4 | {$UNDEF INCLUDE_INTERFACE}
|
|---|
| 5 | var
|
|---|
| 6 | {* This is the value used for transparent pixels. In theory, any
|
|---|
| 7 | color with alpha = 0 is transparent, however it is recommended to
|
|---|
| 8 | use all other channels to zero as well. }
|
|---|
| 9 | BGRAPixelTransparent: TBGRAPixel;
|
|---|
| 10 |
|
|---|
| 11 | {* [#FFFFFF] White opaque }
|
|---|
| 12 | BGRAWhite: TBGRAPixel;
|
|---|
| 13 | {* [#000000] Black opaque }
|
|---|
| 14 | BGRABlack: TBGRAPixel;
|
|---|
| 15 |
|
|---|
| 16 | const
|
|---|
| 17 | {* This color [#000001] looks just like black. It is needed for drawing black
|
|---|
| 18 | shapes using the ''Canvas'' property of ''TBGRABitmap''. This is a standard
|
|---|
| 19 | ''TCanvas'' and when drawing with pure black (''clBlack''), there is no way to know if
|
|---|
| 20 | something has been drawn or if it is transparent }
|
|---|
| 21 | clBlackOpaque = TColor($010000);
|
|---|
| 22 |
|
|---|
| 23 | var
|
|---|
| 24 | //VGA colors
|
|---|
| 25 | VGABlack,VGAGray,VGASilver,VGAWhite,
|
|---|
| 26 | VGAMaroon,VGARed,VGAPurple,VGAFuchsia,
|
|---|
| 27 | VGAGreen,VGALime,VGAOlive,VGAYellow,
|
|---|
| 28 | VGANavy,VGABlue,VGATeal,VGAAqua: TBGRAPixel;
|
|---|
| 29 |
|
|---|
| 30 | //Red colors
|
|---|
| 31 | CSSIndianRed,CSSLightCoral,CSSSalmon,CSSDarkSalmon,
|
|---|
| 32 | CSSRed,CSSCrimson,CSSFireBrick,CSSDarkRed: TBGRAPixel;
|
|---|
| 33 | //Pink colors
|
|---|
| 34 | CSSPink,CSSLightPink,CSSHotPink,CSSDeepPink,
|
|---|
| 35 | CSSMediumVioletRed,CSSPaleVioletRed: TBGRAPixel;
|
|---|
| 36 | //Orange colors
|
|---|
| 37 | CSSLightSalmon,CSSCoral,CSSTomato,CSSOrangeRed,
|
|---|
| 38 | CSSDarkOrange,CSSOrange: TBGRAPixel;
|
|---|
| 39 | //Yellow colors
|
|---|
| 40 | CSSGold,CSSYellow,CSSLightYellow,CSSLemonChiffon,
|
|---|
| 41 | CSSLightGoldenrodYellow,CSSPapayaWhip,CSSMoccasin,CSSPeachPuff,
|
|---|
| 42 | CSSPaleGoldenrod,CSSKhaki,CSSDarkKhaki: TBGRAPixel;
|
|---|
| 43 | //Purple colors
|
|---|
| 44 | CSSLavender,CSSThistle,CSSPlum,CSSViolet,
|
|---|
| 45 | CSSOrchid,CSSFuchsia,CSSMagenta,CSSMediumOrchid,
|
|---|
| 46 | CSSMediumPurple,CSSBlueViolet,CSSDarkViolet,CSSDarkOrchid,
|
|---|
| 47 | CSSDarkMagenta,CSSPurple,CSSIndigo,CSSDarkSlateBlue,
|
|---|
| 48 | CSSSlateBlue,CSSMediumSlateBlue: TBGRAPixel;
|
|---|
| 49 | //Green colors
|
|---|
| 50 | CSSGreenYellow,CSSChartreuse,CSSLawnGreen,CSSLime,
|
|---|
| 51 | CSSLimeGreen,CSSPaleGreen,CSSLightGreen,CSSMediumSpringGreen,
|
|---|
| 52 | CSSSpringGreen,CSSMediumSeaGreen,CSSSeaGreen,CSSForestGreen,
|
|---|
| 53 | CSSGreen,CSSDarkGreen,CSSYellowGreen,CSSOliveDrab,
|
|---|
| 54 | CSSOlive,CSSDarkOliveGreen,CSSMediumAquamarine,CSSDarkSeaGreen,
|
|---|
| 55 | CSSLightSeaGreen,CSSDarkCyan,CSSTeal: TBGRAPixel;
|
|---|
| 56 | //Blue/Cyan colors
|
|---|
| 57 | CSSAqua,CSSCyan,CSSLightCyan,CSSPaleTurquoise,
|
|---|
| 58 | CSSAquamarine,CSSTurquoise,CSSMediumTurquoise,CSSDarkTurquoise,
|
|---|
| 59 | CSSCadetBlue,CSSSteelBlue,CSSLightSteelBlue,CSSPowderBlue,
|
|---|
| 60 | CSSLightBlue,CSSSkyBlue,CSSLightSkyBlue,CSSDeepSkyBlue,
|
|---|
| 61 | CSSDodgerBlue,CSSCornflowerBlue,CSSRoyalBlue,CSSBlue,
|
|---|
| 62 | CSSMediumBlue,CSSDarkBlue,CSSNavy,CSSMidnightBlue: TBGRAPixel;
|
|---|
| 63 | //Brown colors
|
|---|
| 64 | CSSCornsilk, CSSBlanchedAlmond, CSSBisque, CSSNavajoWhite,
|
|---|
| 65 | CSSWheat, CSSBurlyWood, CSSTan, CSSRosyBrown,
|
|---|
| 66 | CSSSandyBrown, CSSGoldenrod, CSSDarkGoldenrod, CSSPeru,
|
|---|
| 67 | CSSChocolate, CSSSaddleBrown, CSSSienna, CSSBrown,
|
|---|
| 68 | CSSMaroon: TBGRAPixel;
|
|---|
| 69 | //White colors
|
|---|
| 70 | CSSWhite, CSSSnow, CSSHoneydew, CSSMintCream,
|
|---|
| 71 | CSSAzure, CSSAliceBlue, CSSGhostWhite, CSSWhiteSmoke,
|
|---|
| 72 | CSSSeashell, CSSBeige, CSSOldLace, CSSFloralWhite,
|
|---|
| 73 | CSSIvory, CSSAntiqueWhite, CSSLinen, CSSLavenderBlush,
|
|---|
| 74 | CSSMistyRose: TBGRAPixel;
|
|---|
| 75 | //Gray colors
|
|---|
| 76 | CSSGainsboro, CSSLightGray, CSSSilver, CSSDarkGray,
|
|---|
| 77 | CSSGray, CSSDimGray, CSSLightSlateGray, CSSSlateGray,
|
|---|
| 78 | CSSDarkSlateGray, CSSBlack: TBGRAPixel;
|
|---|
| 79 |
|
|---|
| 80 | type
|
|---|
| 81 | TBGRAColorDefinition = record
|
|---|
| 82 | Name: string;
|
|---|
| 83 | Color: TBGRAPixel;
|
|---|
| 84 | end;
|
|---|
| 85 |
|
|---|
| 86 | { TBGRAColorList }
|
|---|
| 87 | {* Contains a fixed list of colors }
|
|---|
| 88 | TBGRAColorList = class
|
|---|
| 89 | protected
|
|---|
| 90 | FFinished: boolean;
|
|---|
| 91 | FNbColors: integer;
|
|---|
| 92 | FColors: array of TBGRAColorDefinition;
|
|---|
| 93 | function GetByIndex(Index: integer): TBGRAPixel;
|
|---|
| 94 | function GetByName(Name: string): TBGRAPixel;
|
|---|
| 95 | function GetName(Index: integer): string;
|
|---|
| 96 | procedure Add(Name: string; out Color: TBGRAPixel; red,green,blue: byte); overload;
|
|---|
| 97 | public
|
|---|
| 98 | {** Creates an empty color list }
|
|---|
| 99 | constructor Create;
|
|---|
| 100 | {** Add a color to the list }
|
|---|
| 101 | procedure Add(Name: string; const Color: TBGRAPixel); overload;
|
|---|
| 102 | {** Ends the color list and prevents further modifications }
|
|---|
| 103 | procedure Finished;
|
|---|
| 104 | {** Returns the index of a color with a given name }
|
|---|
| 105 | function IndexOf(Name: string): integer;
|
|---|
| 106 | {** Returns the index of a color. Colors are considered to match if
|
|---|
| 107 | the difference is less than or equal to ''AMaxDiff'' }
|
|---|
| 108 | function IndexOfColor(const AColor: TBGRAPixel; AMaxDiff: Word = 0): integer;
|
|---|
| 109 |
|
|---|
| 110 | {** Gets the color associated with a color name }
|
|---|
| 111 | property ByName[Name: string]: TBGRAPixel read GetByName;
|
|---|
| 112 | {** Gets the color at the specified index }
|
|---|
| 113 | property ByIndex[Index: integer]: TBGRAPixel read GetByIndex; default;
|
|---|
| 114 | {** Gets the name of the color at the specified index }
|
|---|
| 115 | property Name[Index: integer]: string read GetName;
|
|---|
| 116 | {** Gets the number of colors }
|
|---|
| 117 | property Count: integer read FNbColors;
|
|---|
| 118 | end;
|
|---|
| 119 |
|
|---|
| 120 | var
|
|---|
| 121 | {* List of VGA colors:
|
|---|
| 122 | * [#000000] Black, [#808080] Gray, [#C0C0C0] Silver, [#FFFFFF] White,
|
|---|
| 123 | * [#800000] Maroon, [#FF0000] Red, [#800080] Purple, [#FF00FF] Fuchsia,
|
|---|
| 124 | * [#008000] Green, [#00FF00] Lime, [#808000] Olive, [#FFFF00] Yellow,
|
|---|
| 125 | * [#000080] Navy, [#0000FF] Blue, [#008080] Teal, [#00FFFF] Aqua.
|
|---|
| 126 | * Shortcut constants are provided: [#000000] ''VGABlack'', [#808080] ''VGAGray''... }
|
|---|
| 127 | VGAColors: TBGRAColorList;
|
|---|
| 128 | {* List of [http://www.w3schools.com/cssref/css_colornames.asp web colors].
|
|---|
| 129 | Shortcut constants are provided: [#000000] ''CSSBlack'', [#FF0000] ''CSSRed''... }
|
|---|
| 130 | CSSColors: TBGRAColorList;
|
|---|
| 131 |
|
|---|
| 132 | {------------------- string conversion ------------------------}
|
|---|
| 133 |
|
|---|
| 134 | {* Converts a ''TBGRAPixel'' value into a string, using color names provided in ''AColorList'', and
|
|---|
| 135 | considering that a color matches in the color list if its difference is within ''AMaxDiff'' }
|
|---|
| 136 | function BGRAToStr(c: TBGRAPixel; AColorList: TBGRAColorList = nil; AMaxDiff: Word= 0): string;
|
|---|
| 137 | {* Converts a fully defined string into a ''TBGRAPixel'' value. Color names from ''VGAColors'' and ''CSSColors''
|
|---|
| 138 | are used if there is an exact match }
|
|---|
| 139 | function StrToBGRA(str: string): TBGRAPixel; overload;
|
|---|
| 140 | {* Converts a string into a ''TBGRAPixel'' value. If the value is not fully defined or that
|
|---|
| 141 | there is an error, ''DefaultColor'' is returned.
|
|---|
| 142 | Color names from ''VGAColors'' and ''CSSColors'' are used if there is an exact match. }
|
|---|
| 143 | function StrToBGRA(str: string; const DefaultColor: TBGRAPixel): TBGRAPixel; overload;
|
|---|
| 144 | {* Converts a string into a ''TBGRAPixel'' value. If the value is not fully defined, missing channels (expressed with '?')
|
|---|
| 145 | are filled with fallbackValues. You can check if there was an error with the provided boolean.
|
|---|
| 146 | Color names from ''VGAColors'' and ''CSSColors'' are used if there is an exact match. }
|
|---|
| 147 | function PartialStrToBGRA(str: string; const fallbackValues: TBGRAPixel; out error: boolean): TBGRAPixel;
|
|---|
| 148 | {* Converts a string into a ''TBGRAPixel'' value into ''parsedValue''. ''parsedValue'' is not changed if
|
|---|
| 149 | some channels are missing (expressed with '?'). You can check if there was an error with the provided boolean.
|
|---|
| 150 | Color names from ''VGAColors'' and ''CSSColors'' are used if there is an exact match. }
|
|---|
| 151 | procedure TryStrToBGRA(str: string; var parsedValue: TBGRAPixel; out missingValues: boolean; out error: boolean);
|
|---|
| 152 | {$ENDIF}
|
|---|
| 153 |
|
|---|
| 154 | {$IFDEF INCLUDE_IMPLEMENTATION}
|
|---|
| 155 | {$UNDEF INCLUDE_IMPLEMENTATION}
|
|---|
| 156 | { TBGRAColorList }
|
|---|
| 157 |
|
|---|
| 158 | function TBGRAColorList.GetByIndex(Index: integer): TBGRAPixel;
|
|---|
| 159 | begin
|
|---|
| 160 | if (Index < 0) or (Index >= FNbColors) then
|
|---|
| 161 | result := BGRAPixelTransparent
|
|---|
| 162 | else
|
|---|
| 163 | result := FColors[Index].Color;
|
|---|
| 164 | end;
|
|---|
| 165 |
|
|---|
| 166 | function TBGRAColorList.GetByName(Name: string): TBGRAPixel;
|
|---|
| 167 | var i: integer;
|
|---|
| 168 | begin
|
|---|
| 169 | i := IndexOf(Name);
|
|---|
| 170 | if i = -1 then
|
|---|
| 171 | result := BGRAPixelTransparent
|
|---|
| 172 | else
|
|---|
| 173 | result := FColors[i].Color;
|
|---|
| 174 | end;
|
|---|
| 175 |
|
|---|
| 176 | function TBGRAColorList.GetName(Index: integer): string;
|
|---|
| 177 | begin
|
|---|
| 178 | if (Index < 0) or (Index >= FNbColors) then
|
|---|
| 179 | result := ''
|
|---|
| 180 | else
|
|---|
| 181 | result := FColors[Index].Name;
|
|---|
| 182 | end;
|
|---|
| 183 |
|
|---|
| 184 | procedure TBGRAColorList.Add(Name: string; out Color: TBGRAPixel; red, green,
|
|---|
| 185 | blue: byte);
|
|---|
| 186 | begin
|
|---|
| 187 | Color := BGRA(red,green,blue);
|
|---|
| 188 | Add(Name,Color);
|
|---|
| 189 | end;
|
|---|
| 190 |
|
|---|
| 191 | constructor TBGRAColorList.Create;
|
|---|
| 192 | begin
|
|---|
| 193 | FNbColors:= 0;
|
|---|
| 194 | FColors := nil;
|
|---|
| 195 | FFinished:= false;
|
|---|
| 196 | end;
|
|---|
| 197 |
|
|---|
| 198 | procedure TBGRAColorList.Add(Name: string; const Color: TBGRAPixel);
|
|---|
| 199 | begin
|
|---|
| 200 | if FFinished then
|
|---|
| 201 | raise Exception.Create('This list is already finished');
|
|---|
| 202 | if length(FColors) = FNbColors then
|
|---|
| 203 | SetLength(FColors, FNbColors*2+1);
|
|---|
| 204 | FColors[FNbColors].Name := Name;
|
|---|
| 205 | FColors[FNbColors].Color := Color;
|
|---|
| 206 | inc(FNbColors);
|
|---|
| 207 | end;
|
|---|
| 208 |
|
|---|
| 209 | procedure TBGRAColorList.Finished;
|
|---|
| 210 | begin
|
|---|
| 211 | if FFinished then exit;
|
|---|
| 212 | FFinished := true;
|
|---|
| 213 | SetLength(FColors, FNbColors);
|
|---|
| 214 | end;
|
|---|
| 215 |
|
|---|
| 216 | function TBGRAColorList.IndexOf(Name: string): integer;
|
|---|
| 217 | var i: integer;
|
|---|
| 218 | begin
|
|---|
| 219 | for i := 0 to FNbColors-1 do
|
|---|
| 220 | if CompareText(Name, FColors[i].Name) = 0 then
|
|---|
| 221 | begin
|
|---|
| 222 | result := i;
|
|---|
| 223 | exit;
|
|---|
| 224 | end;
|
|---|
| 225 | result := -1;
|
|---|
| 226 | end;
|
|---|
| 227 |
|
|---|
| 228 | function TBGRAColorList.IndexOfColor(const AColor: TBGRAPixel; AMaxDiff: Word = 0): integer;
|
|---|
| 229 | var i: integer;
|
|---|
| 230 | MinDiff,CurDiff: Word;
|
|---|
| 231 | begin
|
|---|
| 232 | if AMaxDiff = 0 then
|
|---|
| 233 | begin
|
|---|
| 234 | for i := 0 to FNbColors-1 do
|
|---|
| 235 | if AColor = FColors[i].Color then
|
|---|
| 236 | begin
|
|---|
| 237 | result := i;
|
|---|
| 238 | exit;
|
|---|
| 239 | end;
|
|---|
| 240 | result := -1;
|
|---|
| 241 | end else
|
|---|
| 242 | begin
|
|---|
| 243 | MinDiff := AMaxDiff;
|
|---|
| 244 | result := -1;
|
|---|
| 245 | for i := 0 to FNbColors-1 do
|
|---|
| 246 | begin
|
|---|
| 247 | CurDiff := BGRAWordDiff(AColor,FColors[i].Color);
|
|---|
| 248 | if CurDiff <= MinDiff then
|
|---|
| 249 | begin
|
|---|
| 250 | result := i;
|
|---|
| 251 | MinDiff := CurDiff;
|
|---|
| 252 | if MinDiff = 0 then exit;
|
|---|
| 253 | end;
|
|---|
| 254 | end;
|
|---|
| 255 | end;
|
|---|
| 256 | end;
|
|---|
| 257 |
|
|---|
| 258 | {------------------- string conversion ---------------------------------}
|
|---|
| 259 |
|
|---|
| 260 | { Write a color in hexadecimal format RRGGBBAA or using the name in a color list }
|
|---|
| 261 | function BGRAToStr(c: TBGRAPixel; AColorList: TBGRAColorList = nil; AMaxDiff: Word= 0): string;
|
|---|
| 262 | var idx: integer;
|
|---|
| 263 | begin
|
|---|
| 264 | if Assigned(AColorList) then
|
|---|
| 265 | begin
|
|---|
| 266 | idx := AColorList.IndexOfColor(c, AMaxDiff);
|
|---|
| 267 | if idx<> -1 then
|
|---|
| 268 | begin
|
|---|
| 269 | result := AColorList.Name[idx];
|
|---|
| 270 | exit;
|
|---|
| 271 | end;
|
|---|
| 272 | end;
|
|---|
| 273 | result := IntToHex(c.red,2)+IntToHex(c.green,2)+IntToHex(c.Blue,2)+IntToHex(c.Alpha,2);
|
|---|
| 274 | end;
|
|---|
| 275 |
|
|---|
| 276 | type
|
|---|
| 277 | arrayOfString = array of string;
|
|---|
| 278 |
|
|---|
| 279 | function SimpleParseFuncParam(str: string; var flagError: boolean): arrayOfString;
|
|---|
| 280 | var idxOpen,start,cur: integer;
|
|---|
| 281 | begin
|
|---|
| 282 | result := nil;
|
|---|
| 283 | idxOpen := pos('(',str);
|
|---|
| 284 | if idxOpen = 0 then
|
|---|
| 285 | begin
|
|---|
| 286 | start := 1;
|
|---|
| 287 | //find first space
|
|---|
| 288 | while (start <= length(str)) and (str[start]<>' ') do inc(start);
|
|---|
| 289 | end else
|
|---|
| 290 | start := idxOpen+1;
|
|---|
| 291 | cur := start;
|
|---|
| 292 | while cur <= length(str) do
|
|---|
| 293 | begin
|
|---|
| 294 | if str[cur] in[',',')'] then
|
|---|
| 295 | begin
|
|---|
| 296 | setlength(result,length(result)+1);
|
|---|
| 297 | result[high(result)] := trim(copy(str,start,cur-start));
|
|---|
| 298 | start := cur+1;
|
|---|
| 299 | if str[cur] = ')' then exit;
|
|---|
| 300 | end;
|
|---|
| 301 | inc(cur);
|
|---|
| 302 | end;
|
|---|
| 303 | if idxOpen <> 0 then flagError := true; //should exit on ')'
|
|---|
| 304 | if start <= length(str) then
|
|---|
| 305 | begin
|
|---|
| 306 | setlength(result,length(result)+1);
|
|---|
| 307 | result[high(result)] := copy(str,start,length(str)-start+1);
|
|---|
| 308 | end;
|
|---|
| 309 | end;
|
|---|
| 310 |
|
|---|
| 311 | function ParseColorValue(str: string; var flagError: boolean): byte;
|
|---|
| 312 | var pourcent,unclipped,{%H-}errPos: integer;
|
|---|
| 313 | pourcentF: single;
|
|---|
| 314 | pourcentStr: string;
|
|---|
| 315 | begin
|
|---|
| 316 | if str = '' then result := 0 else
|
|---|
| 317 | begin
|
|---|
| 318 | if str[length(str)]='%' then
|
|---|
| 319 | begin
|
|---|
| 320 | pourcentStr := copy(str,1,length(str)-1);
|
|---|
| 321 | val(pourcentStr,pourcent,errPos);
|
|---|
| 322 | if errPos <> 0 then
|
|---|
| 323 | begin
|
|---|
| 324 | val(pourcentStr,pourcentF,errPos);
|
|---|
| 325 | if errPos <> 0 then
|
|---|
| 326 | begin
|
|---|
| 327 | flagError := true;
|
|---|
| 328 | result := 0;
|
|---|
| 329 | end
|
|---|
| 330 | else
|
|---|
| 331 | begin
|
|---|
| 332 | if pourcentF < 0 then result := 0 else
|
|---|
| 333 | if pourcentF > 100 then result := 255 else
|
|---|
| 334 | result := round(pourcentF*255 / 100);
|
|---|
| 335 | end;
|
|---|
| 336 | end else
|
|---|
| 337 | begin
|
|---|
| 338 | if pourcent < 0 then result := 0 else
|
|---|
| 339 | if pourcent > 100 then result := 255 else
|
|---|
| 340 | result := pourcent*255 div 100;
|
|---|
| 341 | end;
|
|---|
| 342 | end else
|
|---|
| 343 | begin
|
|---|
| 344 | val(str,unclipped,errPos);
|
|---|
| 345 | if errPos <> 0 then flagError := true;
|
|---|
| 346 | if unclipped < 0 then result := 0 else
|
|---|
| 347 | if unclipped > 255 then result := 255 else
|
|---|
| 348 | result := unclipped;
|
|---|
| 349 | end;
|
|---|
| 350 | end;
|
|---|
| 351 | end;
|
|---|
| 352 |
|
|---|
| 353 | //this function returns the parsed value only if it contains no error nor missing values, otherwise
|
|---|
| 354 | //it returns BGRAPixelTransparent
|
|---|
| 355 | function StrToBGRA(str: string): TBGRAPixel;
|
|---|
| 356 | var missingValues, error: boolean;
|
|---|
| 357 | begin
|
|---|
| 358 | result := BGRABlack;
|
|---|
| 359 | TryStrToBGRA(str, result, missingValues, error);
|
|---|
| 360 | if missingValues or error then result := BGRAPixelTransparent;
|
|---|
| 361 | end;
|
|---|
| 362 |
|
|---|
| 363 | //this function changes the content of parsedValue depending on available and parsable information.
|
|---|
| 364 | //set parsedValue to the fallback values before calling this function.
|
|---|
| 365 | //missing values are expressed by empty string or by '?', for example 'rgb(255,?,?,?)' will change only the red value.
|
|---|
| 366 | //note that if alpha is not expressed by the string format, it will be opaque. So 'rgb(255,?,?)' will change the red value and the alpha value.
|
|---|
| 367 | //the last parameter of rgba() is a floating point number where 1 is opaque and 0 is transparent.
|
|---|
| 368 | procedure TryStrToBGRA(str: string; var parsedValue: TBGRAPixel; out missingValues: boolean; out error: boolean);
|
|---|
| 369 | var errPos: integer;
|
|---|
| 370 | values: array of string;
|
|---|
| 371 | alphaF: single;
|
|---|
| 372 | idx: integer;
|
|---|
| 373 | begin
|
|---|
| 374 | str := Trim(str);
|
|---|
| 375 | error := false;
|
|---|
| 376 | if (str = '') or (str = '?') then
|
|---|
| 377 | begin
|
|---|
| 378 | missingValues := true;
|
|---|
| 379 | exit;
|
|---|
| 380 | end else
|
|---|
| 381 | missingValues := false;
|
|---|
| 382 | str := StringReplace(lowerCase(str),'grey','gray',[]);
|
|---|
| 383 |
|
|---|
| 384 | //VGA color names
|
|---|
| 385 | idx := VGAColors.IndexOf(str);
|
|---|
| 386 | if idx <> -1 then
|
|---|
| 387 | begin
|
|---|
| 388 | parsedValue := VGAColors[idx];
|
|---|
| 389 | exit;
|
|---|
| 390 | end;
|
|---|
| 391 | if str='transparent' then parsedValue := BGRAPixelTransparent else
|
|---|
| 392 | begin
|
|---|
| 393 | //check CSS color
|
|---|
| 394 | idx := CSSColors.IndexOf(str);
|
|---|
| 395 | if idx <> -1 then
|
|---|
| 396 | begin
|
|---|
| 397 | parsedValue := CSSColors[idx];
|
|---|
| 398 | exit;
|
|---|
| 399 | end;
|
|---|
| 400 |
|
|---|
| 401 | //CSS RGB notation
|
|---|
| 402 | if (copy(str,1,4)='rgb(') or (copy(str,1,5)='rgba(') or
|
|---|
| 403 | (copy(str,1,4)='rgb ') or (copy(str,1,5)='rgba ') then
|
|---|
| 404 | begin
|
|---|
| 405 | values := SimpleParseFuncParam(str,error);
|
|---|
| 406 | if (length(values)=3) or (length(values)=4) then
|
|---|
| 407 | begin
|
|---|
| 408 | if (values[0] <> '') and (values[0] <> '?') then
|
|---|
| 409 | parsedValue.red := ParseColorValue(values[0], error)
|
|---|
| 410 | else
|
|---|
| 411 | missingValues := true;
|
|---|
| 412 | if (values[1] <> '') and (values[1] <> '?') then
|
|---|
| 413 | parsedValue.green := ParseColorValue(values[1], error)
|
|---|
| 414 | else
|
|---|
| 415 | missingValues := true;
|
|---|
| 416 | if (values[2] <> '') and (values[2] <> '?') then
|
|---|
| 417 | parsedValue.blue := ParseColorValue(values[2], error)
|
|---|
| 418 | else
|
|---|
| 419 | missingValues := true;
|
|---|
| 420 | if length(values)=4 then
|
|---|
| 421 | begin
|
|---|
| 422 | if (values[3] <> '') and (values[3] <> '?') then
|
|---|
| 423 | begin
|
|---|
| 424 | val(values[3],alphaF,errPos);
|
|---|
| 425 | if errPos <> 0 then
|
|---|
| 426 | begin
|
|---|
| 427 | parsedValue.alpha := 255;
|
|---|
| 428 | error := true;
|
|---|
| 429 | end
|
|---|
| 430 | else
|
|---|
| 431 | begin
|
|---|
| 432 | if alphaF < 0 then
|
|---|
| 433 | parsedValue.alpha := 0 else
|
|---|
| 434 | if alphaF > 1 then
|
|---|
| 435 | parsedValue.alpha := 255
|
|---|
| 436 | else
|
|---|
| 437 | parsedValue.alpha := round(alphaF*255);
|
|---|
| 438 | end;
|
|---|
| 439 | end else
|
|---|
| 440 | missingValues := true;
|
|---|
| 441 | end else
|
|---|
| 442 | parsedValue.alpha := 255;
|
|---|
| 443 | end else
|
|---|
| 444 | error := true;
|
|---|
| 445 | exit;
|
|---|
| 446 | end;
|
|---|
| 447 |
|
|---|
| 448 | //remove HTML notation header
|
|---|
| 449 | if str[1]='#' then delete(str,1,1);
|
|---|
| 450 |
|
|---|
| 451 | //add alpha if missing (if you want an undefined alpha use '??' or '?')
|
|---|
| 452 | if length(str)=6 then str += 'FF';
|
|---|
| 453 | if length(str)=3 then str += 'F';
|
|---|
| 454 |
|
|---|
| 455 | //hex notation
|
|---|
| 456 | if length(str)=8 then
|
|---|
| 457 | begin
|
|---|
| 458 | if copy(str,1,2) <> '??' then
|
|---|
| 459 | begin
|
|---|
| 460 | val('$'+copy(str,1,2),parsedValue.red,errPos);
|
|---|
| 461 | if errPos <> 0 then error := true;
|
|---|
| 462 | end else missingValues := true;
|
|---|
| 463 | if copy(str,3,2) <> '??' then
|
|---|
| 464 | begin
|
|---|
| 465 | val('$'+copy(str,3,2),parsedValue.green,errPos);
|
|---|
| 466 | if errPos <> 0 then error := true;
|
|---|
| 467 | end else missingValues := true;
|
|---|
| 468 | if copy(str,5,2) <> '??' then
|
|---|
| 469 | begin
|
|---|
| 470 | val('$'+copy(str,5,2),parsedValue.blue,errPos);
|
|---|
| 471 | if errPos <> 0 then error := true;
|
|---|
| 472 | end else missingValues := true;
|
|---|
| 473 | if copy(str,7,2) <> '??' then
|
|---|
| 474 | begin
|
|---|
| 475 | val('$'+copy(str,7,2),parsedValue.alpha,errPos);
|
|---|
| 476 | if errPos <> 0 then
|
|---|
| 477 | begin
|
|---|
| 478 | error := true;
|
|---|
| 479 | parsedValue.alpha := 255;
|
|---|
| 480 | end;
|
|---|
| 481 | end else missingValues := true;
|
|---|
| 482 | end else
|
|---|
| 483 | if length(str)=4 then
|
|---|
| 484 | begin
|
|---|
| 485 | if str[1] <> '?' then
|
|---|
| 486 | begin
|
|---|
| 487 | val('$'+str[1],parsedValue.red,errPos);
|
|---|
| 488 | if errPos <> 0 then error := true;
|
|---|
| 489 | parsedValue.red *= $11;
|
|---|
| 490 | end else missingValues := true;
|
|---|
| 491 | if str[2] <> '?' then
|
|---|
| 492 | begin
|
|---|
| 493 | val('$'+str[2],parsedValue.green,errPos);
|
|---|
| 494 | if errPos <> 0 then error := true;
|
|---|
| 495 | parsedValue.green *= $11;
|
|---|
| 496 | end else missingValues := true;
|
|---|
| 497 | if str[3] <> '?' then
|
|---|
| 498 | begin
|
|---|
| 499 | val('$'+str[3],parsedValue.blue,errPos);
|
|---|
| 500 | if errPos <> 0 then error := true;
|
|---|
| 501 | parsedValue.blue *= $11;
|
|---|
| 502 | end else missingValues := true;
|
|---|
| 503 | if str[4] <> '?' then
|
|---|
| 504 | begin
|
|---|
| 505 | val('$'+str[4],parsedValue.alpha,errPos);
|
|---|
| 506 | if errPos <> 0 then
|
|---|
| 507 | begin
|
|---|
| 508 | error := true;
|
|---|
| 509 | parsedValue.alpha := 255;
|
|---|
| 510 | end else
|
|---|
| 511 | parsedValue.alpha *= $11;
|
|---|
| 512 | end else missingValues := true;
|
|---|
| 513 | end else
|
|---|
| 514 | error := true; //string format not recognised
|
|---|
| 515 | end;
|
|---|
| 516 |
|
|---|
| 517 | end;
|
|---|
| 518 |
|
|---|
| 519 | //this function returns the values that can be read from the string, otherwise
|
|---|
| 520 | //it fills the gaps with the fallback values. The error boolean is True only
|
|---|
| 521 | //if there was invalid values, it is not set to True if there was missing values.
|
|---|
| 522 | function PartialStrToBGRA(str: string; const fallbackValues: TBGRAPixel; out
|
|---|
| 523 | error: boolean): TBGRAPixel;
|
|---|
| 524 | var missingValues: boolean;
|
|---|
| 525 | begin
|
|---|
| 526 | result := fallbackValues;
|
|---|
| 527 | TryStrToBGRA(str, result, missingValues, error);
|
|---|
| 528 | end;
|
|---|
| 529 |
|
|---|
| 530 | { Read a color, for example in hexadecimal format RRGGBB(AA) or RGB(A). Partial colors are not accepted by this function. }
|
|---|
| 531 | function StrToBGRA(str: string; const DefaultColor: TBGRAPixel): TBGRAPixel;
|
|---|
| 532 | var missingValues, error: boolean;
|
|---|
| 533 | begin
|
|---|
| 534 | result := BGRABlack;
|
|---|
| 535 | TryStrToBGRA(str, result, missingValues, error);
|
|---|
| 536 | if missingValues or error then result := DefaultColor;
|
|---|
| 537 | end;
|
|---|
| 538 |
|
|---|
| 539 | function BlueGreenRedToBGRA(blue,green,red: byte): TBGRAPixel;
|
|---|
| 540 | begin
|
|---|
| 541 | result := BGRA(red,green,blue);
|
|---|
| 542 | end;
|
|---|
| 543 |
|
|---|
| 544 | {$ENDIF}
|
|---|
| 545 |
|
|---|
| 546 | {$IFDEF INCLUDE_INIT}
|
|---|
| 547 | {$UNDEF INCLUDE_INIT}
|
|---|
| 548 | BGRAPixelTransparent := BGRA(0,0,0,0);
|
|---|
| 549 | BGRAWhite := BGRA(255,255,255);
|
|---|
| 550 | BGRABlack := BGRA(0,0,0);
|
|---|
| 551 |
|
|---|
| 552 | VGAColors := TBGRAColorList.Create;
|
|---|
| 553 | VGAColors.Add('Black',VGABlack,0,0,0);
|
|---|
| 554 | VGAColors.Add('Gray',VGAGray,128,128,128);
|
|---|
| 555 | VGAColors.Add('Silver',VGASilver,192,192,192);
|
|---|
| 556 | VGAColors.Add('White',VGAWhite,255,255,255);
|
|---|
| 557 | VGAColors.Add('Maroon',VGAMaroon,128,0,0);
|
|---|
| 558 | VGAColors.Add('Red',VGARed,255,0,0);
|
|---|
| 559 | VGAColors.Add('Purple',VGAPurple,128,0,128);
|
|---|
| 560 | VGAColors.Add('Fuchsia',VGAFuchsia,255,0,255);
|
|---|
| 561 | VGAColors.Add('Green',VGAGreen,0,128,0);
|
|---|
| 562 | VGAColors.Add('Lime',VGALime,0,255,0);
|
|---|
| 563 | VGAColors.Add('Olive',VGAOlive,128,128,0);
|
|---|
| 564 | VGAColors.Add('Yellow',VGAYellow,255,255,0);
|
|---|
| 565 | VGAColors.Add('Navy',VGANavy,0,0,128);
|
|---|
| 566 | VGAColors.Add('Blue',VGABlue,0,0,255);
|
|---|
| 567 | VGAColors.Add('Teal',VGATeal,0,128,128);
|
|---|
| 568 | VGAColors.Add('Aqua',VGAAqua,0,255,255);
|
|---|
| 569 | VGAColors.Finished;
|
|---|
| 570 |
|
|---|
| 571 | //Red colors
|
|---|
| 572 | CSSIndianRed:= BlueGreenRedToBGRA(92, 92, 205);
|
|---|
| 573 | CSSLightCoral:= BlueGreenRedToBGRA(128, 128, 240);
|
|---|
| 574 | CSSSalmon:= BlueGreenRedToBGRA(114, 128, 250);
|
|---|
| 575 | CSSDarkSalmon:= BlueGreenRedToBGRA(122, 150, 233);
|
|---|
| 576 | CSSRed:= BlueGreenRedToBGRA(0, 0, 255);
|
|---|
| 577 | CSSCrimson:= BlueGreenRedToBGRA(60, 20, 220);
|
|---|
| 578 | CSSFireBrick:= BlueGreenRedToBGRA(34, 34, 178);
|
|---|
| 579 | CSSDarkRed:= BlueGreenRedToBGRA(0, 0, 139);
|
|---|
| 580 |
|
|---|
| 581 | //Pink colors
|
|---|
| 582 | CSSPink:= BlueGreenRedToBGRA(203, 192, 255);
|
|---|
| 583 | CSSLightPink:= BlueGreenRedToBGRA(193, 182, 255);
|
|---|
| 584 | CSSHotPink:= BlueGreenRedToBGRA(180, 105, 255);
|
|---|
| 585 | CSSDeepPink:= BlueGreenRedToBGRA(147, 20, 255);
|
|---|
| 586 | CSSMediumVioletRed:= BlueGreenRedToBGRA(133, 21, 199);
|
|---|
| 587 | CSSPaleVioletRed:= BlueGreenRedToBGRA(147, 112, 219);
|
|---|
| 588 |
|
|---|
| 589 | //Orange colors
|
|---|
| 590 | CSSLightSalmon:= BlueGreenRedToBGRA(122, 160, 255);
|
|---|
| 591 | CSSCoral:= BlueGreenRedToBGRA(80, 127, 255);
|
|---|
| 592 | CSSTomato:= BlueGreenRedToBGRA(71, 99, 255);
|
|---|
| 593 | CSSOrangeRed:= BlueGreenRedToBGRA(0, 69, 255);
|
|---|
| 594 | CSSDarkOrange:= BlueGreenRedToBGRA(0, 140, 255);
|
|---|
| 595 | CSSOrange:= BlueGreenRedToBGRA(0, 165, 255);
|
|---|
| 596 |
|
|---|
| 597 | //Yellow colors
|
|---|
| 598 | CSSGold:= BlueGreenRedToBGRA(0, 215, 255);
|
|---|
| 599 | CSSYellow:= BlueGreenRedToBGRA(0, 255, 255);
|
|---|
| 600 | CSSLightYellow:= BlueGreenRedToBGRA(224, 255, 255);
|
|---|
| 601 | CSSLemonChiffon:= BlueGreenRedToBGRA(205, 250, 255);
|
|---|
| 602 | CSSLightGoldenrodYellow:= BlueGreenRedToBGRA(210, 250, 250);
|
|---|
| 603 | CSSPapayaWhip:= BlueGreenRedToBGRA(213, 239, 255);
|
|---|
| 604 | CSSMoccasin:= BlueGreenRedToBGRA(181, 228, 255);
|
|---|
| 605 | CSSPeachPuff:= BlueGreenRedToBGRA(185, 218, 255);
|
|---|
| 606 | CSSPaleGoldenrod:= BlueGreenRedToBGRA(170, 232, 238);
|
|---|
| 607 | CSSKhaki:= BlueGreenRedToBGRA(140, 230, 240);
|
|---|
| 608 | CSSDarkKhaki:= BlueGreenRedToBGRA(107, 183, 189);
|
|---|
| 609 |
|
|---|
| 610 | //Purple colors
|
|---|
| 611 | CSSLavender:= BlueGreenRedToBGRA(250, 230, 230);
|
|---|
| 612 | CSSThistle:= BlueGreenRedToBGRA(216, 191, 216);
|
|---|
| 613 | CSSPlum:= BlueGreenRedToBGRA(221, 160, 221);
|
|---|
| 614 | CSSViolet:= BlueGreenRedToBGRA(238, 130, 238);
|
|---|
| 615 | CSSOrchid:= BlueGreenRedToBGRA(214, 112, 218);
|
|---|
| 616 | CSSFuchsia:= BlueGreenRedToBGRA(255, 0, 255);
|
|---|
| 617 | CSSMagenta:= BlueGreenRedToBGRA(255, 0, 255);
|
|---|
| 618 | CSSMediumOrchid:= BlueGreenRedToBGRA(211, 85, 186);
|
|---|
| 619 | CSSMediumPurple:= BlueGreenRedToBGRA(219, 112, 147);
|
|---|
| 620 | CSSBlueViolet:= BlueGreenRedToBGRA(226, 43, 138);
|
|---|
| 621 | CSSDarkViolet:= BlueGreenRedToBGRA(211, 0, 148);
|
|---|
| 622 | CSSDarkOrchid:= BlueGreenRedToBGRA(204, 50, 153);
|
|---|
| 623 | CSSDarkMagenta:= BlueGreenRedToBGRA(139, 0, 139);
|
|---|
| 624 | CSSPurple:= BlueGreenRedToBGRA(128, 0, 128);
|
|---|
| 625 | CSSIndigo:= BlueGreenRedToBGRA(130, 0, 75);
|
|---|
| 626 | CSSDarkSlateBlue:= BlueGreenRedToBGRA(139, 61, 72);
|
|---|
| 627 | CSSSlateBlue:= BlueGreenRedToBGRA(205, 90, 106);
|
|---|
| 628 | CSSMediumSlateBlue:= BlueGreenRedToBGRA(238, 104, 123);
|
|---|
| 629 |
|
|---|
| 630 | //Green colors
|
|---|
| 631 | CSSGreenYellow:= BlueGreenRedToBGRA(47, 255, 173);
|
|---|
| 632 | CSSChartreuse:= BlueGreenRedToBGRA(0, 255, 127);
|
|---|
| 633 | CSSLawnGreen:= BlueGreenRedToBGRA(0, 252, 124);
|
|---|
| 634 | CSSLime:= BlueGreenRedToBGRA(0, 255, 0);
|
|---|
| 635 | CSSLimeGreen:= BlueGreenRedToBGRA(50, 205, 50);
|
|---|
| 636 | CSSPaleGreen:= BlueGreenRedToBGRA(152, 251, 152);
|
|---|
| 637 | CSSLightGreen:= BlueGreenRedToBGRA(144, 238, 144);
|
|---|
| 638 | CSSMediumSpringGreen:= BlueGreenRedToBGRA(154, 250, 0);
|
|---|
| 639 | CSSSpringGreen:= BlueGreenRedToBGRA(127, 255, 0);
|
|---|
| 640 | CSSMediumSeaGreen:= BlueGreenRedToBGRA(113, 179, 60);
|
|---|
| 641 | CSSSeaGreen:= BlueGreenRedToBGRA(87, 139, 46);
|
|---|
| 642 | CSSForestGreen:= BlueGreenRedToBGRA(34, 139, 34);
|
|---|
| 643 | CSSGreen:= BlueGreenRedToBGRA(0, 128, 0);
|
|---|
| 644 | CSSDarkGreen:= BlueGreenRedToBGRA(0, 100, 0);
|
|---|
| 645 | CSSYellowGreen:= BlueGreenRedToBGRA(50, 205, 154);
|
|---|
| 646 | CSSOliveDrab:= BlueGreenRedToBGRA(35, 142, 107);
|
|---|
| 647 | CSSOlive:= BlueGreenRedToBGRA(0, 128, 128);
|
|---|
| 648 | CSSDarkOliveGreen:= BlueGreenRedToBGRA(47, 107, 85);
|
|---|
| 649 | CSSMediumAquamarine:= BlueGreenRedToBGRA(170, 205, 102);
|
|---|
| 650 | CSSDarkSeaGreen:= BlueGreenRedToBGRA(143, 188, 143);
|
|---|
| 651 | CSSLightSeaGreen:= BlueGreenRedToBGRA(170, 178, 32);
|
|---|
| 652 | CSSDarkCyan:= BlueGreenRedToBGRA(139, 139, 0);
|
|---|
| 653 | CSSTeal:= BlueGreenRedToBGRA(128, 128, 0);
|
|---|
| 654 |
|
|---|
| 655 | //Blue/Cyan colors
|
|---|
| 656 | CSSAqua:= BlueGreenRedToBGRA(255, 255, 0);
|
|---|
| 657 | CSSCyan:= BlueGreenRedToBGRA(255, 255, 0);
|
|---|
| 658 | CSSLightCyan:= BlueGreenRedToBGRA(255, 255, 224);
|
|---|
| 659 | CSSPaleTurquoise:= BlueGreenRedToBGRA(238, 238, 175);
|
|---|
| 660 | CSSAquamarine:= BlueGreenRedToBGRA(212, 255, 127);
|
|---|
| 661 | CSSTurquoise:= BlueGreenRedToBGRA(208, 224, 64);
|
|---|
| 662 | CSSMediumTurquoise:= BlueGreenRedToBGRA(204, 209, 72);
|
|---|
| 663 | CSSDarkTurquoise:= BlueGreenRedToBGRA(209, 206, 0);
|
|---|
| 664 | CSSCadetBlue:= BlueGreenRedToBGRA(160, 158, 95);
|
|---|
| 665 | CSSSteelBlue:= BlueGreenRedToBGRA(180, 130, 70);
|
|---|
| 666 | CSSLightSteelBlue:= BlueGreenRedToBGRA(222, 196, 176);
|
|---|
| 667 | CSSPowderBlue:= BlueGreenRedToBGRA(230, 224, 176);
|
|---|
| 668 | CSSLightBlue:= BlueGreenRedToBGRA(230, 216, 173);
|
|---|
| 669 | CSSSkyBlue:= BlueGreenRedToBGRA(235, 206, 135);
|
|---|
| 670 | CSSLightSkyBlue:= BlueGreenRedToBGRA(250, 206, 135);
|
|---|
| 671 | CSSDeepSkyBlue:= BlueGreenRedToBGRA(255, 191, 0);
|
|---|
| 672 | CSSDodgerBlue:= BlueGreenRedToBGRA(255, 144, 30);
|
|---|
| 673 | CSSCornflowerBlue:= BlueGreenRedToBGRA(237, 149, 100);
|
|---|
| 674 | CSSRoyalBlue:= BlueGreenRedToBGRA(255, 105, 65);
|
|---|
| 675 | CSSBlue:= BlueGreenRedToBGRA(255, 0, 0);
|
|---|
| 676 | CSSMediumBlue:= BlueGreenRedToBGRA(205, 0, 0);
|
|---|
| 677 | CSSDarkBlue:= BlueGreenRedToBGRA(139, 0, 0);
|
|---|
| 678 | CSSNavy:= BlueGreenRedToBGRA(128, 0, 0);
|
|---|
| 679 | CSSMidnightBlue:= BlueGreenRedToBGRA(112, 25, 25);
|
|---|
| 680 |
|
|---|
| 681 | //Brown colors
|
|---|
| 682 | CSSCornsilk:= BlueGreenRedToBGRA(220, 248, 255);
|
|---|
| 683 | CSSBlanchedAlmond:= BlueGreenRedToBGRA(205, 235, 255);
|
|---|
| 684 | CSSBisque:= BlueGreenRedToBGRA(196, 228, 255);
|
|---|
| 685 | CSSNavajoWhite:= BlueGreenRedToBGRA(173, 222, 255);
|
|---|
| 686 | CSSWheat:= BlueGreenRedToBGRA(179, 222, 245);
|
|---|
| 687 | CSSBurlyWood:= BlueGreenRedToBGRA(135, 184, 222);
|
|---|
| 688 | CSSTan:= BlueGreenRedToBGRA(140, 180, 210);
|
|---|
| 689 | CSSRosyBrown:= BlueGreenRedToBGRA(143, 143, 188);
|
|---|
| 690 | CSSSandyBrown:= BlueGreenRedToBGRA(96, 164, 244);
|
|---|
| 691 | CSSGoldenrod:= BlueGreenRedToBGRA(32, 165, 218);
|
|---|
| 692 | CSSDarkGoldenrod:= BlueGreenRedToBGRA(11, 134, 184);
|
|---|
| 693 | CSSPeru:= BlueGreenRedToBGRA(63, 133, 205);
|
|---|
| 694 | CSSChocolate:= BlueGreenRedToBGRA(30, 105, 210);
|
|---|
| 695 | CSSSaddleBrown:= BlueGreenRedToBGRA(19, 69, 139);
|
|---|
| 696 | CSSSienna:= BlueGreenRedToBGRA(45, 82, 160);
|
|---|
| 697 | CSSBrown:= BlueGreenRedToBGRA(42, 42, 165);
|
|---|
| 698 | CSSMaroon:= BlueGreenRedToBGRA(0, 0, 128);
|
|---|
| 699 |
|
|---|
| 700 | //White colors
|
|---|
| 701 | CSSWhite:= BlueGreenRedToBGRA(255, 255, 255);
|
|---|
| 702 | CSSSnow:= BlueGreenRedToBGRA(250, 250, 255);
|
|---|
| 703 | CSSHoneydew:= BlueGreenRedToBGRA(240, 255, 250);
|
|---|
| 704 | CSSMintCream:= BlueGreenRedToBGRA(250, 255, 245);
|
|---|
| 705 | CSSAzure:= BlueGreenRedToBGRA(255, 255, 240);
|
|---|
| 706 | CSSAliceBlue:= BlueGreenRedToBGRA(255, 248, 240);
|
|---|
| 707 | CSSGhostWhite:= BlueGreenRedToBGRA(255, 248, 248);
|
|---|
| 708 | CSSWhiteSmoke:= BlueGreenRedToBGRA(245, 245, 245);
|
|---|
| 709 | CSSSeashell:= BlueGreenRedToBGRA(255, 245, 238);
|
|---|
| 710 | CSSBeige:= BlueGreenRedToBGRA(220, 245, 245);
|
|---|
| 711 | CSSOldLace:= BlueGreenRedToBGRA(230, 245, 253);
|
|---|
| 712 | CSSFloralWhite:= BlueGreenRedToBGRA(240, 250, 255);
|
|---|
| 713 | CSSIvory:= BlueGreenRedToBGRA(240, 255, 255);
|
|---|
| 714 | CSSAntiqueWhite:= BlueGreenRedToBGRA(215, 235, 250);
|
|---|
| 715 | CSSLinen:= BlueGreenRedToBGRA(230, 240, 250);
|
|---|
| 716 | CSSLavenderBlush:= BlueGreenRedToBGRA(245, 240, 255);
|
|---|
| 717 | CSSMistyRose:= BlueGreenRedToBGRA(255, 228, 255);
|
|---|
| 718 |
|
|---|
| 719 | //Gray colors
|
|---|
| 720 | CSSGainsboro:= BlueGreenRedToBGRA(220, 220, 220);
|
|---|
| 721 | CSSLightGray:= BlueGreenRedToBGRA(211, 211, 211);
|
|---|
| 722 | CSSSilver:= BlueGreenRedToBGRA(192, 192, 192);
|
|---|
| 723 | CSSDarkGray:= BlueGreenRedToBGRA(169, 169, 169);
|
|---|
| 724 | CSSGray:= BlueGreenRedToBGRA(128, 128, 128);
|
|---|
| 725 | CSSDimGray:= BlueGreenRedToBGRA(105, 105, 105);
|
|---|
| 726 | CSSLightSlateGray:= BlueGreenRedToBGRA(153, 136, 119);
|
|---|
| 727 | CSSSlateGray:= BlueGreenRedToBGRA(144, 128, 112);
|
|---|
| 728 | CSSDarkSlateGray:= BlueGreenRedToBGRA(79, 79, 47);
|
|---|
| 729 | CSSBlack:= BlueGreenRedToBGRA(0, 0, 0);
|
|---|
| 730 |
|
|---|
| 731 | CSSColors := TBGRAColorList.Create;
|
|---|
| 732 | CSSColors.Add('AliceBlue',CSSAliceBlue);
|
|---|
| 733 | CSSColors.Add('AntiqueWhite',CSSAntiqueWhite);
|
|---|
| 734 | CSSColors.Add('Aqua',CSSAqua);
|
|---|
| 735 | CSSColors.Add('Aquamarine',CSSAquamarine);
|
|---|
| 736 | CSSColors.Add('Azure',CSSAzure);
|
|---|
| 737 | CSSColors.Add('Beige',CSSBeige);
|
|---|
| 738 | CSSColors.Add('Bisque',CSSBisque);
|
|---|
| 739 | CSSColors.Add('Black',CSSBlack);
|
|---|
| 740 | CSSColors.Add('BlanchedAlmond',CSSBlanchedAlmond);
|
|---|
| 741 | CSSColors.Add('Blue',CSSBlue);
|
|---|
| 742 | CSSColors.Add('BlueViolet',CSSBlueViolet);
|
|---|
| 743 | CSSColors.Add('Brown',CSSBrown);
|
|---|
| 744 | CSSColors.Add('BurlyWood',CSSBurlyWood);
|
|---|
| 745 | CSSColors.Add('CadetBlue',CSSCadetBlue);
|
|---|
| 746 | CSSColors.Add('Chartreuse',CSSChartreuse);
|
|---|
| 747 | CSSColors.Add('Chocolate',CSSChocolate);
|
|---|
| 748 | CSSColors.Add('Coral',CSSCoral);
|
|---|
| 749 | CSSColors.Add('CornflowerBlue',CSSCornflowerBlue);
|
|---|
| 750 | CSSColors.Add('Cornsilk',CSSCornsilk);
|
|---|
| 751 | CSSColors.Add('Crimson',CSSCrimson);
|
|---|
| 752 | CSSColors.Add('Cyan',CSSCyan);
|
|---|
| 753 | CSSColors.Add('DarkBlue',CSSDarkBlue);
|
|---|
| 754 | CSSColors.Add('DarkCyan',CSSDarkCyan);
|
|---|
| 755 | CSSColors.Add('DarkGoldenrod',CSSDarkGoldenrod);
|
|---|
| 756 | CSSColors.Add('DarkGray',CSSDarkGray);
|
|---|
| 757 | CSSColors.Add('DarkGreen',CSSDarkGreen);
|
|---|
| 758 | CSSColors.Add('DarkKhaki',CSSDarkKhaki);
|
|---|
| 759 | CSSColors.Add('DarkMagenta',CSSDarkMagenta);
|
|---|
| 760 | CSSColors.Add('DarkOliveGreen',CSSDarkOliveGreen);
|
|---|
| 761 | CSSColors.Add('DarkOrange',CSSDarkOrange);
|
|---|
| 762 | CSSColors.Add('DarkOrchid',CSSDarkOrchid);
|
|---|
| 763 | CSSColors.Add('DarkRed',CSSDarkRed);
|
|---|
| 764 | CSSColors.Add('DarkSalmon',CSSDarkSalmon);
|
|---|
| 765 | CSSColors.Add('DarkSeaGreen',CSSDarkSeaGreen);
|
|---|
| 766 | CSSColors.Add('DarkSlateBlue',CSSDarkSlateBlue);
|
|---|
| 767 | CSSColors.Add('DarkSlateGray',CSSDarkSlateGray);
|
|---|
| 768 | CSSColors.Add('DarkTurquoise',CSSDarkTurquoise);
|
|---|
| 769 | CSSColors.Add('DarkViolet',CSSDarkViolet);
|
|---|
| 770 | CSSColors.Add('DeepPink',CSSDeepPink);
|
|---|
| 771 | CSSColors.Add('DeepSkyBlue',CSSDeepSkyBlue);
|
|---|
| 772 | CSSColors.Add('DimGray',CSSDimGray);
|
|---|
| 773 | CSSColors.Add('DodgerBlue',CSSDodgerBlue);
|
|---|
| 774 | CSSColors.Add('FireBrick',CSSFireBrick);
|
|---|
| 775 | CSSColors.Add('FloralWhite',CSSFloralWhite);
|
|---|
| 776 | CSSColors.Add('ForestGreen',CSSForestGreen);
|
|---|
| 777 | CSSColors.Add('Fuchsia',CSSFuchsia);
|
|---|
| 778 | CSSColors.Add('Gainsboro',CSSGainsboro);
|
|---|
| 779 | CSSColors.Add('GhostWhite',CSSGhostWhite);
|
|---|
| 780 | CSSColors.Add('Gold',CSSGold);
|
|---|
| 781 | CSSColors.Add('Goldenrod',CSSGoldenrod);
|
|---|
| 782 | CSSColors.Add('Gray',CSSGray);
|
|---|
| 783 | CSSColors.Add('Green',CSSGreen);
|
|---|
| 784 | CSSColors.Add('GreenYellow',CSSGreenYellow);
|
|---|
| 785 | CSSColors.Add('Honeydew',CSSHoneydew);
|
|---|
| 786 | CSSColors.Add('HotPink',CSSHotPink);
|
|---|
| 787 | CSSColors.Add('IndianRed',CSSIndianRed);
|
|---|
| 788 | CSSColors.Add('Indigo',CSSIndigo);
|
|---|
| 789 | CSSColors.Add('Ivory',CSSIvory);
|
|---|
| 790 | CSSColors.Add('Khaki',CSSKhaki);
|
|---|
| 791 | CSSColors.Add('Lavender',CSSLavender);
|
|---|
| 792 | CSSColors.Add('LavenderBlush',CSSLavenderBlush);
|
|---|
| 793 | CSSColors.Add('LawnGreen',CSSLawnGreen);
|
|---|
| 794 | CSSColors.Add('LemonChiffon',CSSLemonChiffon);
|
|---|
| 795 | CSSColors.Add('LightBlue',CSSLightBlue);
|
|---|
| 796 | CSSColors.Add('LightCoral',CSSLightCoral);
|
|---|
| 797 | CSSColors.Add('LightCyan',CSSLightCyan);
|
|---|
| 798 | CSSColors.Add('LightGoldenrodYellow',CSSLightGoldenrodYellow);
|
|---|
| 799 | CSSColors.Add('LightGray',CSSLightGray);
|
|---|
| 800 | CSSColors.Add('LightGreen',CSSLightGreen);
|
|---|
| 801 | CSSColors.Add('LightPink',CSSLightPink);
|
|---|
| 802 | CSSColors.Add('LightSalmon',CSSLightSalmon);
|
|---|
| 803 | CSSColors.Add('LightSeaGreen',CSSLightSeaGreen);
|
|---|
| 804 | CSSColors.Add('LightSkyBlue',CSSLightSkyBlue);
|
|---|
| 805 | CSSColors.Add('LightSlateGray',CSSLightSlateGray);
|
|---|
| 806 | CSSColors.Add('LightSteelBlue',CSSLightSteelBlue);
|
|---|
| 807 | CSSColors.Add('LightYellow',CSSLightYellow);
|
|---|
| 808 | CSSColors.Add('Lime',CSSLime);
|
|---|
| 809 | CSSColors.Add('LimeGreen',CSSLimeGreen);
|
|---|
| 810 | CSSColors.Add('Linen',CSSLinen);
|
|---|
| 811 | CSSColors.Add('Magenta',CSSMagenta);
|
|---|
| 812 | CSSColors.Add('Maroon',CSSMaroon);
|
|---|
| 813 | CSSColors.Add('MediumAquamarine',CSSMediumAquamarine);
|
|---|
| 814 | CSSColors.Add('MediumBlue',CSSMediumBlue);
|
|---|
| 815 | CSSColors.Add('MediumOrchid',CSSMediumOrchid);
|
|---|
| 816 | CSSColors.Add('MediumPurple',CSSMediumPurple);
|
|---|
| 817 | CSSColors.Add('MediumSeaGreen',CSSMediumSeaGreen);
|
|---|
| 818 | CSSColors.Add('MediumSlateBlue',CSSMediumSlateBlue);
|
|---|
| 819 | CSSColors.Add('MediumSpringGreen',CSSMediumSpringGreen);
|
|---|
| 820 | CSSColors.Add('MediumTurquoise',CSSMediumTurquoise);
|
|---|
| 821 | CSSColors.Add('MediumVioletRed',CSSMediumVioletRed);
|
|---|
| 822 | CSSColors.Add('MidnightBlue',CSSMidnightBlue);
|
|---|
| 823 | CSSColors.Add('MintCream',CSSMintCream);
|
|---|
| 824 | CSSColors.Add('MistyRose',CSSMistyRose);
|
|---|
| 825 | CSSColors.Add('Moccasin',CSSMoccasin);
|
|---|
| 826 | CSSColors.Add('NavajoWhite',CSSNavajoWhite);
|
|---|
| 827 | CSSColors.Add('Navy',CSSNavy);
|
|---|
| 828 | CSSColors.Add('OldLace',CSSOldLace);
|
|---|
| 829 | CSSColors.Add('Olive',CSSOlive);
|
|---|
| 830 | CSSColors.Add('OliveDrab',CSSOliveDrab);
|
|---|
| 831 | CSSColors.Add('Orange',CSSOrange);
|
|---|
| 832 | CSSColors.Add('OrangeRed',CSSOrangeRed);
|
|---|
| 833 | CSSColors.Add('Orchid',CSSOrchid);
|
|---|
| 834 | CSSColors.Add('PaleGoldenrod',CSSPaleGoldenrod);
|
|---|
| 835 | CSSColors.Add('PaleGreen',CSSPaleGreen);
|
|---|
| 836 | CSSColors.Add('PaleTurquoise',CSSPaleTurquoise);
|
|---|
| 837 | CSSColors.Add('PaleVioletRed',CSSPaleVioletRed);
|
|---|
| 838 | CSSColors.Add('PapayaWhip',CSSPapayaWhip);
|
|---|
| 839 | CSSColors.Add('PeachPuff',CSSPeachPuff);
|
|---|
| 840 | CSSColors.Add('Peru',CSSPeru);
|
|---|
| 841 | CSSColors.Add('Pink',CSSPink);
|
|---|
| 842 | CSSColors.Add('Plum',CSSPlum);
|
|---|
| 843 | CSSColors.Add('PowderBlue',CSSPowderBlue);
|
|---|
| 844 | CSSColors.Add('Purple',CSSPurple);
|
|---|
| 845 | CSSColors.Add('Red',CSSRed);
|
|---|
| 846 | CSSColors.Add('RosyBrown',CSSRosyBrown);
|
|---|
| 847 | CSSColors.Add('RoyalBlue',CSSRoyalBlue);
|
|---|
| 848 | CSSColors.Add('SaddleBrown',CSSSaddleBrown);
|
|---|
| 849 | CSSColors.Add('Salmon',CSSSalmon);
|
|---|
| 850 | CSSColors.Add('SandyBrown',CSSSandyBrown);
|
|---|
| 851 | CSSColors.Add('SeaGreen',CSSSeaGreen);
|
|---|
| 852 | CSSColors.Add('Seashell',CSSSeashell);
|
|---|
| 853 | CSSColors.Add('Sienna',CSSSienna);
|
|---|
| 854 | CSSColors.Add('Silver',CSSSilver);
|
|---|
| 855 | CSSColors.Add('SkyBlue',CSSSkyBlue);
|
|---|
| 856 | CSSColors.Add('SlateBlue',CSSSlateBlue);
|
|---|
| 857 | CSSColors.Add('SlateGray',CSSSlateGray);
|
|---|
| 858 | CSSColors.Add('Snow',CSSSnow);
|
|---|
| 859 | CSSColors.Add('SpringGreen',CSSSpringGreen);
|
|---|
| 860 | CSSColors.Add('SteelBlue',CSSSteelBlue);
|
|---|
| 861 | CSSColors.Add('Tan',CSSTan);
|
|---|
| 862 | CSSColors.Add('Teal',CSSTeal);
|
|---|
| 863 | CSSColors.Add('Thistle',CSSThistle);
|
|---|
| 864 | CSSColors.Add('Tomato',CSSTomato);
|
|---|
| 865 | CSSColors.Add('Turquoise',CSSTurquoise);
|
|---|
| 866 | CSSColors.Add('Violet',CSSViolet);
|
|---|
| 867 | CSSColors.Add('Wheat',CSSWheat);
|
|---|
| 868 | CSSColors.Add('White',CSSWhite);
|
|---|
| 869 | CSSColors.Add('WhiteSmoke',CSSWhiteSmoke);
|
|---|
| 870 | CSSColors.Add('Yellow',CSSYellow);
|
|---|
| 871 | CSSColors.Add('YellowGreen',CSSYellowGreen);
|
|---|
| 872 | CSSColors.Finished;
|
|---|
| 873 | {$ENDIF}
|
|---|
| 874 |
|
|---|
| 875 | {$IFDEF INCLUDE_FINAL}
|
|---|
| 876 | {$UNDEF INCLUDE_FINAL}
|
|---|
| 877 | CSSColors.Free;
|
|---|
| 878 | VGAColors.Free;
|
|---|
| 879 | {$ENDIF}
|
|---|