Skip to main content

get it basically working

ID
656b936
date
2021-11-26 07:43:27+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
fbe8eea
message
get it basically working
changed files
2 files, 17 additions, 17 deletions

Changed files

Cargo.lock (11946) → Cargo.lock (11922)

diff --git a/Cargo.lock b/Cargo.lock
index 5e07550..8639677 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -177,11 +177,9 @@ version = "0.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "45b02102b24e8f7163d7f794f2a250e3b5da067994695521310338da0db6ae2c"
 dependencies = [
- "image",
  "palette",
  "rand",
  "rand_chacha",
- "structopt",
 ]
 
 [[package]]

src/main.rs (2112) → src/main.rs (2176)

diff --git a/src/main.rs b/src/main.rs
index e8ad16f..679be9c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,10 +1,9 @@
 #[macro_use]
 extern crate clap;
 
-use clap::{App, Arg};
-// use kmeans_colors::{get_kmeans_hamerly, MapColor};
-use palette::{FromColor, IntoColor, Lab, Pixel, Srgb, Srgba};
-use kmeans_colors::{get_kmeans, get_kmeans_hamerly, Calculate, Kmeans, MapColor, Sort};
+use clap::{App, Arg, ArgGroup};
+use palette::{Lab, Pixel, Srgb, Srgba};
+use kmeans_colors::{get_kmeans_hamerly};
 
 fn main() {
     let matches =
@@ -25,6 +24,12 @@ fn main() {
                     .default_value("5")
                     .takes_value(true)
             )
+            .arg(
+                Arg::with_name("no-palette")
+                    .long("no-palette")
+                    .help("Just print the hex values, not colour previews")
+                    .takes_value(false)
+            )
             .get_matches();
 
     // This .unwrap() is safe because "path" is a required param
@@ -47,7 +52,7 @@ fn main() {
         .collect();
 
     let max_iterations = 20;
-    let converge = 5.0;
+    let converge = 50.0;
     let verbose = false;
     let seed: u64 = 0;
 
@@ -59,16 +64,13 @@ fn main() {
         &lab,
         seed,
     );
-    //
-    // let rgb = &run_result.centroids
-    //     .iter()
-    //     .map(|x| Srgb::from(*x).into_format())
-    //     .collect::<Vec<Srgb<u8>>>();
 
-    // println!("{:?}", run_result);
+    let rgb = &run_result.centroids
+        .iter()
+        .map(|x| Srgb::from(*x).into_format())
+        .collect::<Vec<Srgb<u8>>>();
 
-    println!("matches = {:?}", matches);
-    println!("count = {:?}", count);
-    // println!("lab = {:?}", lab);
-    println!("Hello, world!");
+    for c in rgb {
+        println!("\x1B[38;2;{};{};{}m▇ #{:02x}{:02x}{:02x}\x1B[0m", c.red, c.green, c.blue, c.red, c.green, c.blue);
+    }
 }