flexmeasures.ui.utils.color_defaults

Functions

flexmeasures.ui.utils.color_defaults.darken_color(hex_color: str, percentage: int) str

Darkens a hex color by a given percentage towards black.

Parameters:
  • hex_color – The hex color string (e.g. “#abc” or “#aabbcc”).

  • percentage – The percentage to darken the color (0-100).

Returns:

The darkened hex color string.

Examples:
>>> darken_color("#ffffff", 0)
'#ffffff'
>>> darken_color("#ffffff", 100)
'#000000'
>>> darken_color("#123456", 50)
'#091a2b'
>>> darken_color("#abc", 50)
'#555d66'
flexmeasures.ui.utils.color_defaults.ensure_6_digit_hex(hex_color: str) str

Expand 3-digit hex to 6-digit.

flexmeasures.ui.utils.color_defaults.get_color_settings(account: Account | None) dict

This function returns the primary and secondary color settings for the UI.

It also provides variations of the primary and secondary colors, such as border color, hover color, and transparent color.

flexmeasures.ui.utils.color_defaults.lighten_color(hex_color: str, percentage: int) str

Lightens a hex color by a given percentage towards white.

Parameters:
  • hex_color – The hex color string (e.g. “#abc” or “#aabbcc”).

  • percentage – The percentage to lighten the color (0-100).

Returns:

The lightened hex color string.

Examples:
>>> lighten_color("#000000", 0)
'#000000'
>>> lighten_color("#000000", 100)
'#ffffff'
>>> lighten_color("#123456", 50)
'#8899aa'
>>> lighten_color("#abc", 50)
'#d4dde5'
flexmeasures.ui.utils.color_defaults.rgba_color(hex_color: str, alpha: float) str