Difference between revisions of "BGRABitmap Color definitions"
From Lazarus wiki
Jump to navigationJump to search (intro) |
|||
Line 1: | Line 1: | ||
List of color definitions and string conversion functions in [[BGRABitmap]] library. | List of color definitions and string conversion functions in [[BGRABitmap]] library. | ||
− | === | + | === Color definitions === |
<table style="border-collapse: collapse;"><tr style="background: white;"><td colspan="3">''BGRAPixelTransparent'': TBGRAPixel = (blue: 0; green: 0; red: 0; alpha: 0);</td></tr> | <table style="border-collapse: collapse;"><tr style="background: white;"><td colspan="3">''BGRAPixelTransparent'': TBGRAPixel = (blue: 0; green: 0; red: 0; alpha: 0);</td></tr> | ||
<tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">This is the value used for transparent pixels. In theory, any color with alpha = 0 is transparent, however it is recommended to use all other channels to zero as well.</td></tr> | <tr style="background: white;"><td width="10%"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;" colspan="2">This is the value used for transparent pixels. In theory, any color with alpha = 0 is transparent, however it is recommended to use all other channels to zero as well.</td></tr> | ||
Line 32: | Line 32: | ||
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Returns the index of a color. Colors are considered to match if the difference is less than or equal to ''AMaxDiff''</td></tr> | <tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Returns the index of a color. Colors are considered to match if the difference is less than or equal to ''AMaxDiff''</td></tr> | ||
<tr style="height: 8px;"><td colspan="3"></td></tr> | <tr style="height: 8px;"><td colspan="3"></td></tr> | ||
− | <tr><td width="10%"></td><td colspan="2" style="background: white;">'''property''' ByName[Name: '''string''']: TBGRAPixel | + | <tr><td width="10%"></td><td colspan="2" style="background: white;">'''property''' ByName[Name: '''string''']: TBGRAPixel</td></tr> |
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Gets the color associated with a color name</td></tr> | <tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Gets the color associated with a color name</td></tr> | ||
<tr style="height: 8px;"><td colspan="3"></td></tr> | <tr style="height: 8px;"><td colspan="3"></td></tr> | ||
− | <tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''property''' ByIndex[Index: integer]: TBGRAPixel | + | <tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''property''' ByIndex[Index: integer]: TBGRAPixel</td></tr> |
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Gets the color at the specified index</td></tr> | <tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Gets the color at the specified index</td></tr> | ||
<tr style="height: 8px;"><td colspan="3"></td></tr> | <tr style="height: 8px;"><td colspan="3"></td></tr> | ||
− | <tr><td width="10%"></td><td colspan="2" style="background: white;">'''property''' Name[Index: integer]: '''string''' | + | <tr><td width="10%"></td><td colspan="2" style="background: white;">'''property''' Name[Index: integer]: '''string'''</td></tr> |
<tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Gets the name of the color at the specified index</td></tr> | <tr><td width="10%"></td><td width="10%" style="background: white;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Gets the name of the color at the specified index</td></tr> | ||
<tr style="height: 8px;"><td colspan="3"></td></tr> | <tr style="height: 8px;"><td colspan="3"></td></tr> | ||
− | <tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''property''' Count: integer | + | <tr><td width="10%"></td><td colspan="2" style="background: #f0f0ff;">'''property''' Count: integer</td></tr> |
<tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Gets the number of colors</td></tr> | <tr><td width="10%"></td><td width="10%" style="background: #f0f0ff;"></td><td style="border: 1px solid #e0e0a0; background: #ffffe4;">Gets the number of colors</td></tr> | ||
<tr style="height: 8px;"><td colspan="3"></td></tr> | <tr style="height: 8px;"><td colspan="3"></td></tr> |
Revision as of 14:42, 30 April 2015
List of color definitions and string conversion functions in BGRABitmap library.
Color definitions
BGRAPixelTransparent: TBGRAPixel = (blue: 0; green: 0; red: 0; alpha: 0); | ||
This is the value used for transparent pixels. In theory, any color with alpha = 0 is transparent, however it is recommended to use all other channels to zero as well. | ||
BGRAWhite: TBGRAPixel = (blue: 255; green: 255; red: 255; alpha: 255); | ||
White opaque | ||
BGRABlack: TBGRAPixel = (blue: 0; green: 0; red: 0; alpha: 255); | ||
Black opaque | ||
clBlackOpaque = TColor($010000); | ||
This color looks just like black. It is needed for drawing black shapes using the Canvas property of TBGRABitmap. This is a standard TCanvas and when drawing with pure black (clBlack), there is no way to know if something has been drawn or if it is transparent | ||
TBGRAColorList = class | ||
Contains a fixed list of colors | ||
constructor Create; | ||
Creates an empty color list | ||
procedure Add(Name: string; const Color: TBGRAPixel); | ||
Add a color to the list | ||
procedure Finished; | ||
Ends the color list and prevents further modifications | ||
function IndexOf(Name: string): integer; | ||
Returns the index of a color with a given name | ||
function IndexOfColor(const AColor: TBGRAPixel; AMaxDiff: Word = 0): integer; | ||
Returns the index of a color. Colors are considered to match if the difference is less than or equal to AMaxDiff | ||
property ByName[Name: string]: TBGRAPixel | ||
Gets the color associated with a color name | ||
property ByIndex[Index: integer]: TBGRAPixel | ||
Gets the color at the specified index | ||
property Name[Index: integer]: string | ||
Gets the name of the color at the specified index | ||
property Count: integer | ||
Gets the number of colors | ||
VGAColors: TBGRAColorList; | ||
List of VGA colors: Black, Gray, Silver, White, Maroon, Red, Purple, Fuchsia, Green, Lime, Olive, Yellow, Navy, Blue, Teal, Aqua. Shortcut constants are provided: VGABlack, VGAGray... | ||
CSSColors: TBGRAColorList; | ||
List of web colors. Shortcut constants are provided: CSSBlack, CSSRed... | ||
function BGRAToStr(c: TBGRAPixel; AColorList: TBGRAColorList = nil; AMaxDiff: Word= 0): string; | ||
Converts a TBGRAPixel value into a string, using color names provided in AColorList, and considering that a color matches in the color list if its difference is within AMaxDiff | ||
function StrToBGRA(str: string): TBGRAPixel; | ||
Converts a fully defined string into a TBGRAPixel value. Color names from VGAColors and CSSColors are used if there is an exact match | ||
function StrToBGRA(str: string; const DefaultColor: TBGRAPixel): TBGRAPixel; | ||
Converts a string into a TBGRAPixel value. If the value is not fully defined or that there is an error, DefaultColor is returned. Color names from VGAColors and CSSColors are used if there is an exact match. | ||
function PartialStrToBGRA(str: string; const fallbackValues: TBGRAPixel; out error: boolean): TBGRAPixel; | ||
Converts a string into a TBGRAPixel value. If the value is not fully defined, missing channels (expressed with '?') are filled with fallbackValues. You can check if there was an error with the provided boolean. Color names from VGAColors and CSSColors are used if there is an exact match. | ||
procedure TryStrToBGRA(str: string; var parsedValue: TBGRAPixel; out missingValues: boolean; out error: boolean); | ||
Converts a string into a TBGRAPixel value into parsedValue. parsedValue is not changed if some channels are missing (expressed with '?'). You can check if there was an error with the provided boolean. Color names from VGAColors and CSSColors are used if there is an exact match. | ||