Pi66

Home | Repos | About | Blog | Gaza

walrs
pywal but if its Fast-Minimal-Simple
git clone https://git.pi66.xyz/walrs

About | Files | Commits | Refs | License


remove clone methods

Author: pixel2175
Date: 2025-06-10 01:26
commit: 8b452318

Stat

M src/get_colors.rs 27 +15 -12
M src/wallpaper.rs 7 +3 -4

Diff

diff --git a/src/get_colors.rs b/src/get_colors.rs
index c54b2b9..9d6a5ae 100644
--- a/src/get_colors.rs
+++ b/src/get_colors.rs
@@ -32,7 +32,7 @@ fn to_gray(r: u8, g: u8, b: u8, v: u8) -> (u8, u8, u8) {
     (gray, gray, gray)
 }

-fn kmeans_colors(len: u8, native_rgba: RgbaImage) -> Vec<(u8, u8, u8)> { +fn kmeans_colors(len: u8, native_rgba: &RgbaImage) -> Vec<(u8, u8, u8)> { let pixels_kmeans: Vec<Lab> = native_rgba .pixels() .filter(|p| p.0[3] > 0) // Filter out transparent pixels @@ -68,7 +68,7 @@ fn kmeans_colors(len: u8, native_rgba: RgbaImage) -> Vec<(u8, u8, u8)> { .collect::<Vec<(u8, u8, u8)>>() }

-fn color_thief_colors(len: u8, native_rgba: RgbaImage) -> Vec<(u8, u8, u8)> { +fn color_thief_colors(len: u8, native_rgba: &RgbaImage) -> Vec<(u8, u8, u8)> { let palette_extract = palette_extract::get_palette_with_options( ...

Show all

diff --git a/src/get_colors.rs b/src/get_colors.rs
index c54b2b9..9d6a5ae 100644
--- a/src/get_colors.rs
+++ b/src/get_colors.rs
@@ -32,7 +32,7 @@ fn to_gray(r: u8, g: u8, b: u8, v: u8) -> (u8, u8, u8) {
     (gray, gray, gray)
 }

-fn kmeans_colors(len: u8, native_rgba: RgbaImage) -> Vec<(u8, u8, u8)> { +fn kmeans_colors(len: u8, native_rgba: &RgbaImage) -> Vec<(u8, u8, u8)> { let pixels_kmeans: Vec<Lab> = native_rgba .pixels() .filter(|p| p.0[3] > 0) // Filter out transparent pixels @@ -68,7 +68,7 @@ fn kmeans_colors(len: u8, native_rgba: RgbaImage) -> Vec<(u8, u8, u8)> { .collect::<Vec<(u8, u8, u8)>>() }

-fn color_thief_colors(len: u8, native_rgba: RgbaImage) -> Vec<(u8, u8, u8)> { +fn color_thief_colors(len: u8, native_rgba: &RgbaImage) -> Vec<(u8, u8, u8)> { let palette_extract = palette_extract::get_palette_with_options( &native_rgba, palette_extract::PixelEncoding::Rgba, @@ -83,7 +83,7 @@ fn color_thief_colors(len: u8, native_rgba: RgbaImage) -> Vec<(u8, u8, u8)> { .collect::<Vec<(u8, u8, u8)>>() }

-fn palette_extract_colors(len: u8, native_rgba: RgbaImage, send: bool) -> Vec<(u8, u8, u8)> { +fn palette_extract_colors(len: u8, native_rgba: &RgbaImage, send: bool) -> Vec<(u8, u8, u8)> { let palette_thief = color_thief::get_palette(&native_rgba, ColorFormat::Rgba, 5, len) .unwrap_or_else(|_| { warning("Backend", "palette thief can't extract the palette", send); @@ -96,7 +96,12 @@ fn palette_extract_colors(len: u8, native_rgba: RgbaImage, send: bool) -> Vec<(u .collect::<Vec<(u8, u8, u8)>>() }

-fn extract_colors(len: u8, backend: &str, native_rgba: RgbaImage, send: bool) -> Vec<(u8, u8, u8)> { +fn extract_colors( + len: u8, + backend: &str, + native_rgba: &RgbaImage, + send: bool, +) -> Vec<(u8, u8, u8)> { match backend { "backends" => { println!( @@ -116,12 +121,10 @@ fn extract_colors(len: u8, backend: &str, native_rgba: RgbaImage, send: bool) -> "palette_extract" => palette_extract_colors(10, native_rgba, send), "all" => { let mut collected: Vec<(u8, u8, u8)> = Vec::new(); - kmeans_colors(len, native_rgba.clone()) - .iter() - .for_each(|c| { - collected.push(*c); - }); - color_thief_colors(len / 3_u8, native_rgba.clone()) + kmeans_colors(len, native_rgba).iter().for_each(|c| { + collected.push(*c); + }); + color_thief_colors(len / 3_u8, native_rgba) .iter() .for_each(|c| { collected.push(*c); @@ -169,11 +172,11 @@ pub fn get_colors(

 let native&#95;rgba = image.to&#95;rgba8();
 let alpha = &#38;native&#95;rgba.get&#95;pixel(0, 0)&#91;3&#93;;

- let mut collect_rgb: Vec<(u8, u8, u8)> = extract_colors(30, backend, native_rgba.clone(), send); + let mut collect_rgb: Vec<(u8, u8, u8)> = extract_colors(30, backend, &native_rgba, send);

 collect&#95;rgb = remove&#95;duplicates(collect&#95;rgb);
 while collect&#95;rgb.len() &#60;= 21 {

- collect_rgb.push(extract_colors(1, backend, native_rgba.clone(), send)[0]); + collect_rgb.push(extract_colors(1, backend, &native_rgba, send)[0]); }

 collect&#95;rgb.sort&#95;by(&#124;a, b&#124; {

diff --git a/src/wallpaper.rs b/src/wallpaper.rs index 12c3fd2..f0002c9 100644 --- a/src/wallpaper.rs +++ b/src/wallpaper.rs @@ -116,9 +116,8 @@ fn set_wm_wallpaper(img: &str, send: bool) { } }

-fn set_desktop_wallpaper(desktop: &str, img: &str, send: bool) { - let d = desktop.to_lowercase(); - let abs_path = get_absolute_path(&d).unwrap_or_else(|| { +fn set_desktop_wallpaper(d: &str, img: &str, send: bool) { + let abs_path = get_absolute_path(img).unwrap_or_else(|| { warning("Wallpaper", "failed to get absolute path", send); img.to_string() }); @@ -380,7 +379,7 @@ pub fn change_wallpaper(img: &str, send: bool) { send, ); } - set_desktop_wallpaper(&d, img, send); + set_desktop_wallpaper(&d.to_lowercase(), img, send); } None => { if send {

// Created by Pi66

// Copyright ©Pi66 2026