Crate terminal_light[][src]

Expand description

This crate answers the question “Is the terminal dark or light?”.

It provides either

  • the background color as RGB
  • the background color’s luma, which varies from 0 (black) to 1 (white)

A use case in a TUI is to determine what set of colors would be more suitable depending on the terminal’s background:

let should_use_light_skin = terminal_light::luma()
    .map_or(false, |luma| luma > 0.6);

Structs

RGB color, with u16 components

Enums

terminal-light error type

Functions

Try to return the RGB background color of the terminal.

Try to return the “luma” value of the terminal’s background, characterizing the “light” of the color, going from 0 (black) to 1 (white).