Skip to content

Commit

Permalink
Replace delta_e depedency with empfindung
Browse files Browse the repository at this point in the history
This removes dependency on ancient lab versions which we were forced to
use due to delta_e lack of maintenance.

Issue: #6
  • Loading branch information
mina86 committed Jul 1, 2021
1 parent fb0a966 commit eef25ed
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 17 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <mina86@mina86.com>"]
keywords = ["ansi", "terminal", "color", "rgb"]
Expand All @@ -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"
Expand Down
7 changes: 1 addition & 6 deletions tests/ansi256.rs
Original file line number Diff line number Diff line change
@@ -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)
}
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 2 additions & 4 deletions tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 1 addition & 4 deletions tools/src/bin/cube.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@
// You should have received a copy of the GNU Lesser General Public License
// along with ansi_colours. If not, see <http://www.gnu.org/licenses/>.

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<F: Fn(u8) -> (u8, u8, u8)>(component: &'static str, to_rgb: F) {
Expand Down

0 comments on commit eef25ed

Please sign in to comment.