Skip to content

Commit 8e86542

Browse files
committed
replace file paths for examples input and output files,
add .png support in Cargo.toml, correct .gitignore
1 parent 71b1434 commit 8e86542

File tree

11 files changed

+32
-25
lines changed

11 files changed

+32
-25
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
target
22
Cargo.lock
3-
*/examples/*.png
3+
example-data/output/*
File renamed without changes.
File renamed without changes.
File renamed without changes.

palette/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ version = "0.3"
6363
default-features = false
6464

6565
[dev-dependencies.image]
66-
version = "0.22"
66+
version = "0.23"
6767
default-features = false
68+
features = ["png"]
6869

6970
[build-dependencies.phf_codegen]
7071
version = "0.8"

palette/examples/color_scheme.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,10 @@ fn main() {
156156
);
157157
}
158158

159-
match image.save("examples/color_scheme.png") {
160-
Ok(()) => println!("see 'examples/color_scheme.png' for the result"),
161-
Err(e) => println!("failed to write 'examples/color_scheme.png': {}", e),
159+
let _ = std::fs::create_dir("example-data/output");
160+
match image.save("example-data/output/color_scheme.png") {
161+
Ok(()) => println!("see 'example-data/output/color_scheme.png' for the result"),
162+
Err(e) => println!("failed to write 'example-data/output/color_scheme.png': {}", e),
162163
}
163164
}
164165

palette/examples/gradient.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ fn main() {
9393
}
9494
}
9595

96-
match image.save("examples/gradient.png") {
97-
Ok(()) => println!("see 'examples/gradient.png' for the result"),
98-
Err(e) => println!("failed to write 'examples/gradient.png': {}", e),
96+
let _ = std::fs::create_dir("example-data/output");
97+
match image.save("example-data/output/gradient.png") {
98+
Ok(()) => println!("see 'example-data/output/gradient.png' for the result"),
99+
Err(e) => println!("failed to write 'example-data/output/gradient.png': {}", e),
99100
}
100101
}

palette/examples/hue.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use palette::{FromColor, Hsl, Hue, IntoColor, Lch, Pixel, Srgb};
22

33
fn main() {
4-
let mut image = image::open("res/fruits.png")
5-
.expect("could not open 'res/fruits.png'")
4+
let mut image = image::open("example-data/input/fruits.png")
5+
.expect("could not open 'example-data/input/fruits.png'")
66
.to_rgb();
77

88
//Shift hue by 180 degrees as HSL in bottom left part, and as LCh in top
@@ -24,8 +24,9 @@ fn main() {
2424
};
2525
}
2626

27-
match image.save("examples/hue.png") {
28-
Ok(()) => println!("see 'examples/hue.png' for the result"),
29-
Err(e) => println!("failed to write 'examples/hue.png': {}", e),
27+
let _ = std::fs::create_dir("example-data/output");
28+
match image.save("example-data/output/hue.png") {
29+
Ok(()) => println!("see 'example-data/output/hue.png' for the result"),
30+
Err(e) => println!("failed to write 'example-data/output/hue.png': {}", e),
3031
}
3132
}

palette/examples/readme_examples.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ mod color_spaces {
1313
let new_color = Srgb::from_color(lch_color.shift_hue(180.0));
1414

1515
display_colors(
16-
"examples/readme_color_spaces.png",
16+
"example-data/output/readme_color_spaces.png",
1717
&[
1818
::palette::Srgb::new(0.8, 0.2, 0.1).into_format(),
1919
new_color.into_format(),
@@ -32,7 +32,7 @@ mod manipulation {
3232
let desaturated = Lch::from_color(color).desaturate(0.5);
3333

3434
display_colors(
35-
"examples/readme_manipulation.png",
35+
"example-data/output/readme_manipulation.png",
3636
&[
3737
Srgb::from_linear(color.into()).into_format(),
3838
Srgb::from_linear(lighter.into()).into_format(),
@@ -58,7 +58,7 @@ mod gradients {
5858
Hsv::from_color(LinSrgb::new(0.1, 1.0, 1.0)),
5959
]);
6060

61-
display_gradients("examples/readme_gradients.png", grad1, grad2);
61+
display_gradients("example-data/output/readme_gradients.png", grad1, grad2);
6262
}
6363
}
6464

@@ -74,6 +74,7 @@ fn display_colors(filename: &str, colors: &[Srgb<u8>]) {
7474
}
7575
}
7676

77+
let _ = std::fs::create_dir("example-data/output");
7778
match image.save(filename) {
7879
Ok(()) => println!("see '{}' for the result", filename),
7980
Err(e) => println!("failed to write '{}': {}", filename, e),

palette/examples/saturate.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use palette::{Hsl, IntoColor, Lch, Pixel, Saturate, Srgb};
33
use image::{GenericImage, GenericImageView};
44

55
fn main() {
6-
let mut image = image::open("res/cat.png")
7-
.expect("could not open 'res/cat.png'")
6+
let mut image = image::open("example-data/input/cat.png")
7+
.expect("could not open 'example-data/input/cat.png'")
88
.to_rgb();
99

1010
let width = image.width();
@@ -59,9 +59,10 @@ fn main() {
5959
}
6060
}
6161
}
62-
63-
match image.save("examples/saturate.png") {
64-
Ok(()) => println!("see 'examples/saturate.png' for the result"),
65-
Err(e) => println!("failed to write 'examples/saturate.png': {}", e),
62+
63+
let _ = std::fs::create_dir("example-data/output");
64+
match image.save("example-data/output/saturate.png") {
65+
Ok(()) => println!("see 'example-data/output/saturate.png' for the result"),
66+
Err(e) => println!("failed to write 'example-data/output/saturate.png': {}", e),
6667
}
6768
}

0 commit comments

Comments
 (0)