1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114 | diff --git a/Cargo.lock b/Cargo.lock
index 6f3c594..3327018 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1061,7 +1061,7 @@ checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b"
[[package]]
name = "walrs"
-version = "1.0.1"
+version = "1.0.2"
dependencies = [
"clap",
"color-thief",
diff --git a/Cargo.toml b/Cargo.toml
index 86a5f4c..91150a2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,9 +1,9 @@
[package]
name = "walrs"
-version = "1.0.1"
+version = "1.0.2"
edition = "2024"
description = "walrs is a fast color scheme generator."
-license = "MIT"
+license = "GPL"
repository = "https://github.com/pixel2175/walrs"
[dependencies]
diff --git a/src/get_colors.rs b/src/get_colors.rs
index 1d85e4a..7c27d51 100644
--- a/src/get_colors.rs
+++ b/src/get_colors.rs
@@ -6,7 +6,7 @@ use std::process::exit;
use std::fs::read;
use crate::utils::warning;
-fn adjust_rgb(r: u8, g: u8, b: u8, brightness: i16, saturation: i16) -> (u8, u8, u8) {
+fn adjust_rgb(r: u8, g: u8, b: u8, brightness: i8, saturation: i8) -> (u8, u8, u8) {
let avg = ((r as u16 + g as u16 + b as u16) / 3) as f32;
let r = ((r as f32 - avg) * (saturation as f32 / 100.0) + avg + brightness as f32).clamp(0.0, 255.0);
@@ -32,11 +32,11 @@ fn to_gray(r: u8, g: u8, b: u8, v: Option<u8>) -> (u8, u8, u8) {
}
}
-fn generate_variation(color: (u8, u8, u8), offset: i16) -> (u8, u8, u8) {
+fn generate_variation(color: (u8, u8, u8), offset: i8) -> (u8, u8, u8) {
adjust_rgb(color.0, color.1, color.2, offset, 50)
}
-pub fn get_colors(image_path: &str,send:bool) -> (Vec<(u8,u8,u8)>,u8){
+pub fn get_colors(image_path: &str,send:bool,brightness: Option<i8>,saturation: Option<i8> ) -> (Vec<(u8,u8,u8)>,u8){
let image = match image::open(image_path) {
Ok(img) => img,
@@ -80,7 +80,7 @@ pub fn get_colors(image_path: &str,send:bool) -> (Vec<(u8,u8,u8)>,u8){
let mut i = 0;
while collect_rgb.len() <= 21 {
let base = collect_rgb[i % collect_rgb.len()];
- let variation = generate_variation(base, 10 * (i as i16 + 1));
+ let variation = generate_variation(base, 10 * (i as i8 + 1));
collect_rgb.push(variation);
i += 1;
}
@@ -97,12 +97,12 @@ pub fn get_colors(image_path: &str,send:bool) -> (Vec<(u8,u8,u8)>,u8){
for color in colors{
let (mut r, mut g, mut b) = collect_rgb[color];
- (r,g,b) = adjust_rgb(r, g, b,-10,80);
+ (r,g,b) = adjust_rgb(r, g, b,brightness.unwrap_or(0),saturation.unwrap_or(0) + 80);
done.push((r,g,b));
}
let (mut r,mut g,mut b) = collect_rgb[20];
- (r,g,b) = adjust_rgb(r,g,b,60,-10);
+ (r,g,b) = adjust_rgb(r,g,b,70,10);
(r,g,b) = to_gray(r, g, b, Some(2));
done[7] = (r,g,b);
done[15] = (r,g,b);
diff --git a/src/main.rs b/src/main.rs
index b8bd192..0d95034 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -27,6 +27,20 @@ struct Arg {
/// set quit mode (no output)
#[arg(short = 'q', action = ArgAction::SetTrue)]
quit: bool,
+
+
+ /// specify the saturation value
+ #[arg(short = 's')]
+ saturation: Option<i8>,
+
+
+ /// specify the brightness value
+ #[arg(short = 'b')]
+ brightness: Option<i8>,
+
+
+
+
}
fn main() {
@@ -63,7 +77,7 @@ fn main() {
}
};
- let palette = get_colors(&image_path, !arg.quit);
+ let palette = get_colors(&image_path, !arg.quit,arg.brightness,arg.saturation);
info("Generate", "generate colors", !arg.quit);
create_template(palette, &image_path);
|