From eef25edf851c0d78e1b68b713a238c5aaf562fbd Mon Sep 17 00:00:00 2001 From: Michal Nazarewicz Date: Thu, 1 Jul 2021 02:02:33 +0200 Subject: [PATCH] Replace delta_e depedency with empfindung This removes dependency on ancient lab versions which we were forced to use due to delta_e lack of maintenance. Issue: https://github.com/mina86/ansi_colours/pull/6 --- Cargo.toml | 6 +++--- tests/ansi256.rs | 7 +------ tools/Cargo.toml | 6 ++---- tools/src/bin/cube.rs | 5 +---- 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1ec69f9..1cd264f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "ansi_colours" description = "true-colour ↔ ANSI terminal palette converter" -version = "1.0.3" +version = "1.0.4" readme = "README.md" authors = ["Michał Nazarewicz "] keywords = ["ansi", "terminal", "color", "rgb"] @@ -16,8 +16,8 @@ edition = "2018" maintenance = { status = "actively-developed" } [dev-dependencies] -delta_e = "^0.2" -lab = "0.*" +empfindung = "0.2" +lab = ">=0.4, <1.0" [build-dependencies] cc = "^1.0" diff --git a/tests/ansi256.rs b/tests/ansi256.rs index e3d65ae..73ba8a6 100644 --- a/tests/ansi256.rs +++ b/tests/ansi256.rs @@ -1,8 +1,3 @@ -extern crate delta_e; -extern crate lab; - -extern crate ansi_colours; - fn to_rgb(index: u8) -> (u8, u8, u8) { ansi_colours::rgb_from_ansi256(index) } @@ -57,7 +52,7 @@ fn best_grey(y: u8) -> u8 { .map(|(idx, v)| (*v, idx as u8 * (36 + 6 + 1) + 16)) .chain((0..24u8).map(|idx| (idx * 10 + 8, idx + 232))) .fold((f32::INFINITY, 0), |best, elem| { - let d = delta_e::DE2000::from_rgb(&grey, &[elem.0, elem.0, elem.0]); + let d = empfindung::de2000::diff_rgb(&grey, &[elem.0, elem.0, elem.0]); if d < best.0 { (d, elem.1) } else { diff --git a/tools/Cargo.toml b/tools/Cargo.toml index 35f25b8..3e20ce9 100644 --- a/tools/Cargo.toml +++ b/tools/Cargo.toml @@ -6,7 +6,5 @@ publish = false edition = "2018" [dependencies] -delta_e = "^0.2" -# delta_e uses lab 0.7 so we cannot go up to 0.8 -# https://github.com/elliotekj/DeltaE/pull/5 -lab = "^0.7" +empfindung = "0.2" +lab = ">=0.4, <1.0" diff --git a/tools/src/bin/cube.rs b/tools/src/bin/cube.rs index d182625..79bc296 100644 --- a/tools/src/bin/cube.rs +++ b/tools/src/bin/cube.rs @@ -14,13 +14,10 @@ // You should have received a copy of the GNU Lesser General Public License // along with ansi_colours. If not, see . -extern crate delta_e; -extern crate lab; - static CUBE_VALUES: [u8; 6] = [0, 95, 135, 175, 215, 255]; fn distance(x: &lab::Lab, y: (u8, u8, u8)) -> f32 { - delta_e::DE2000::new(*x, lab::Lab::from_rgb(&[y.0, y.1, y.2])) + empfindung::de2000::diff(*x, lab::Lab::from_rgb(&[y.0, y.1, y.2])) } fn find_best (u8, u8, u8)>(component: &'static str, to_rgb: F) {