--- title: "contrastColor (Kontrastfarbe errechnen)" slug: "calc-function-contrast-color" updated: 2026-02-17T08:00:19Z published: 2026-02-17T08:00:19Z canonical: "docs.lobstersoftware.com/calc-function-contrast-color" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.lobstersoftware.com/llms.txt > Use this file to discover all available pages before exploring further. # contrastColor (Kontrastfarbe errechnen) > [!NOTE] > Die Funktion $contrastColor errechnet entweder "Schwarz" oder "Weiß" als Kontrastfarbe zur übergebenen Farbe. Wird der Farbcode als Hexadezimalzahl zurückgegeben, wird automatisch ein '#' vorangestellt, damit die Farbe direkt in HTML Markups verwendet werden kann. > > > [!TIP] > > Tooltip > > > > Syntax: *$contrastColor(color[,resultAsInteger=false])* > > > > | Parameter | Beschreibung | > > | --- | --- | > > | `color` | Ein beliebiger, als Farbe interpretierbarer, Wert. z.B. 9965381 oder "9965381" oder "#980f45" | > > | `resultAsInteger(optional)` | Ein bool'scher Wert, welcher definiert, ob das Ergebnis der Funktion als 16 Bit Ganzzahl (true) oder im 6-stelligen Hexadezimalformat mit vorangestelltem '#' Zeichen (false) zurückgeliefert werden soll. Wird dieser Parameter nicht angegeben, so wird er als *false* interpretiert **Tipp**: 0 wird ebenfalls als false und 1 als true interpretiert | > > > > Liefert Schwarz oder Weiß als Kontrastfarbe zur übergebenen Farbe. > > > > Beispiel: $contrastColor(#980f45) - Liefert #ffffff (Weiß) *Siehe auch* [cssColor](/v1/docs/calc-function-css-color) ## Syntax *$contrastColor(color[,resultAsInteger=false])* ## Parameter | Name | Beschreibung | | --- | --- | | color | Ein beliebiger, als Farbe interpretierbarer, Wert. z.B. 9965381 oder "9965381" oder "#980f45" | | resultAsInteger (optional) | Ein bool'scher Wert, welcher definiert, ob das Ergebnis der Funktion als 16 Bit Ganzzahl (true) oder im 6-stelligen Hexadezimalformat mit vorangestelltem '#' Zeichen (false) zurückgeliefert werden soll. Wird dieser Parameter nicht angegeben, so wird er als *false* interpretiert **Tipp**: 0 wird ebenfalls als false und 1 als true interpretiert | ## Rückgabewert Schwarz oder Weiß als Kontrastfarbe zur übergebenen Farbe. Beispiele | Eingabe | Ausgabe | Farbe | | --- | --- | --- | | color = "#ffffff" resultAsInteger = false | "#000000" | Schwarz | | color = "#ffffff" resultAsInteger = true | 0 | Schwarz | | color = 0 resultAsInteger = false | "#ffffff" | Weiß | | color = 0 resultAsInteger = true | 16581374 | Weiß | | color = "#980f45" | "#ffffff" | Weiß |