Skip to main content

gpui_kit_material_color/dynamic/
dislike.rs

1// Copyright 2023 Google LLC
2// SPDX-License-Identifier: Apache-2.0
3// Ported to Rust from material-color-utilities (typescript/dislike), modified
4// for this crate. See licenses/material-color-utilities.txt.
5
6//! Universally disliked colors: dark yellow-greens (Palmer and Schloss, 2010).
7use super::hct::Hct;
8
9/// Whether a color is a non-neutral dark yellow-green.
10pub fn is_disliked(hct: Hct) -> bool {
11    let hue = hct.hue().round();
12    (90. ..=111.).contains(&hue) && hct.chroma().round() > 16. && hct.tone().round() < 65.
13}
14
15/// A disliked color lightened to tone 70; any other color unchanged.
16pub fn fix_if_disliked(hct: Hct) -> Hct {
17    if is_disliked(hct) {
18        Hct::from_hct(hct.hue(), hct.chroma(), 70.)
19    } else {
20        hct
21    }
22}