BGRABitmap Color definitions: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | - | ||
| 1 | + | List of color definitions and string conversion functions in [[BGRABitmap]] library. They are provided by [BGRABitmapTypes unit](https://bgrabitmap.github.io/doc/BGRABitmapTypes.html). | |
| 2 | 2 | ||
| 3 | 3 | ### Color definitions | |
| 4 | 4 | ||
| 5 | - | ||
| 6 | - | ||
| 7 | - | ||
| 8 | - | ||
| 9 | - | ||
| 10 | - | ||
| 11 | - | ||
| 12 | - | ||
| 13 | - | ||
| 14 | - | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - | ||
| 25 | - | ||
| 26 | - | ||
| 27 | - | ||
| 28 | - | ||
| 29 | - | ||
| 30 | - | ||
| 31 | - | ||
| 32 | - | ||
| 33 | - | ||
| 34 | - | ||
| 35 | - | ||
| 36 | - | ||
| 37 | - | ||
| 38 | - | ||
| 39 | - | ||
| 40 | - | ||
| 41 | - | ||
| 42 | - | ||
| 43 | - | ||
| 44 | - | ||
| 45 | - | ||
| 46 | - | ||
| 47 | - | ||
| 48 | - | ||
| 5 | + | *BGRAPixelTransparent*: TBGRAPixel; | |
| 6 | + | ||
| 7 | + | 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. | |
| 8 | + | ||
| 9 | + | *BGRAWhite*: TBGRAPixel; | |
| 10 | + | ||
| 11 | + | White opaque | |
| 12 | + | ||
| 13 | + | *BGRABlack*: TBGRAPixel; | |
| 14 | + | ||
| 15 | + | Black opaque | |
| 16 | + | ||
| 17 | + | *clBlackOpaque* = TColor(\$010000); | |
| 18 | + | ||
| 19 | + | 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 | |
| 20 | + | ||
| 21 | + | *TBGRAColorList* = **class** | |
| 22 | + | ||
| 23 | + | Contains a fixed list of colors | |
| 24 | + | ||
| 25 | + | **constructor** Create; | |
| 26 | + | ||
| 27 | + | Creates an empty color list | |
| 28 | + | ||
| 29 | + | **procedure** Add(Name: **string**; **const** Color: TBGRAPixel); **overload**; | |
| 30 | + | ||
| 31 | + | Add a color to the list | |
| 32 | + | ||
| 33 | + | **procedure** Finished; | |
| 34 | + | ||
| 35 | + | Ends the color list and prevents further modifications | |
| 36 | + | ||
| 37 | + | **function** IndexOf(Name: **string**): integer; | |
| 38 | + | ||
| 39 | + | Returns the index of a color with a given name | |
| 40 | + | ||
| 41 | + | **function** IndexOfColor(**const** AColor: TBGRAPixel; AMaxDiff: Word = 0): integer; | |
| 42 | + | ||
| 43 | + | Returns the index of a color. Colors are considered to match if the difference is less than or equal to *AMaxDiff* | |
| 44 | + | ||
| 45 | + | **property** ByName\[Name: **string**\]: TBGRAPixel **read** GetByName; | |
| 46 | + | ||
| 47 | + | Gets the color associated with a color name | |
| 48 | + | ||
| 49 | + | **property** ByIndex\[Index: integer\]: TBGRAPixel **read** GetByIndex; **default**; | |
| 50 | + | ||
| 51 | + | Gets the color at the specified index | |
| 52 | + | ||
| 53 | + | **property** Name\[Index: integer\]: **string** **read** GetName; | |
| 54 | + | ||
| 55 | + | Gets the name of the color at the specified index | |
| 56 | + | ||
| 57 | + | **property** Count: integer **read** FNbColors; | |
| 58 | + | ||
| 59 | + | Gets the number of colors | |
| 60 | + | ||
| 61 | + | *VGAColors*: TBGRAColorList; | |
| 62 | + | ||
| 63 | + | List of VGA colors: | |
| 64 | + | ||
| 65 | + | Black, Gray, Silver, White, Maroon, Red, Purple, Fuchsia, Green, Lime, Olive, Yellow, Navy, Blue, Teal, Aqua. | |
| 66 | + | ||
| 67 | + | Shortcut constants are provided: *VGABlack*, *VGAGray*... | |
| 68 | + | ||
| 69 | + | *CSSColors*: TBGRAColorList; | |
| 70 | + | ||
| 71 | + | List of [web colors](https://www.w3schools.com/cssref/css_colors.asp). | |
| 72 | + | ||
| 73 | + | Shortcut constants are provided: *CSSBlack*, *CSSRed*... | |
| 74 | + | ||
| 75 | + | **function** BGRAToStr(c: TBGRAPixel; AColorList: TBGRAColorList = **nil**; | |
| 76 | + | ||
| 77 | + | 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* | |
| 78 | + | ||
| 79 | + | **function** StrToBGRA(str: **string**): TBGRAPixel; **overload**; | |
| 80 | + | ||
| 81 | + | Converts a fully defined string into a TBGRAPixel value. Color names from *VGAColors* and *CSSColors* are used if there is an exact match | |
| 82 | + | ||
| 83 | + | **function** StrToBGRA(str: **string**; **const** DefaultColor: TBGRAPixel): TBGRAPixel; **overload**; | |
| 84 | + | ||
| 85 | + | 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. | |
| 86 | + | ||
| 87 | + | **function** PartialStrToBGRA(str: **string**; **const** fallbackValues: TBGRAPixel; **out** error: boolean): TBGRAPixel; | |
| 88 | + | ||
| 89 | + | 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. | |
| 90 | + | ||
| 91 | + | **procedure** TryStrToBGRA(str: **string**; **var** parsedValue: TBGRAPixel; **out** missingValues: boolean; **out** error: boolean); | |
| 92 | + | ||
| 93 | + | 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. | |
| 94 | + | ||
| 49 | 95 | ## See also | |
| 50 | 96 | ||
| 51 | - | ||
| 97 | + | - [[BGRABitmap XYZ|Using XYZ colorspace in BGRABitmap]] | |
| 52 | 98 | ||
| 53 | 99 | --- | |
| 54 | - | ||
| 100 | + | *From the Free Pascal wiki, page "BGRABitmap Color definitions", as it stood on 2024-04-03 after a change by Circular, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 101 | + | Category: BGRABitmap |
