W3cubDocs

/GTK 4.0

Colors

GTK extends the CSS syntax with several additional ways to specify colors.

The first is a reference to a color defined via a define-color rule in CSS. The syntax for define-color rules is as follows:

define-color Name Color

To refer to the color defined by a define-color rule, prefix the name with @.

GTK also supports color expressions, which allow colors to be transformed to new ones. Color expressions can be nested, providing a rich language to define colors. Color expressions resemble functions, taking 1 or more colors and in some cases a number as arguments.

lighter(Color)

produces a brigher variant of Color

darker(Color)

produces a darker variant of Color

shade(Color, Number)

changes the lightness of Color. The number ranges from 0 for black to 2 for white.

alpha(Color, Number)

replaces the alpha value of color with number (between 0 and 1)

mix(Color1, Color2, Number)

interpolates between the two colors

© 2005–2020 The GNOME Project
Licensed under the GNU Lesser General Public License version 2.1 or later.
https://developer.gnome.org/gtk4/4.0/ch39s02.html