-
Notifications
You must be signed in to change notification settings - Fork 119
/
utils.rs
33 lines (24 loc) · 919 Bytes
/
utils.rs
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
#[cfg(feature = "images")]
use noise::utils::{NoiseImage, NoiseMap};
#[allow(dead_code)]
#[cfg(feature = "images")]
pub fn write_example_to_file(map: &NoiseMap, filename: &str) {
use std::{fs, path::Path};
let target = Path::new("example_images/").join(Path::new(filename));
fs::create_dir_all(target.clone().parent().expect("No parent directory found."))
.expect("Failed to create directories.");
map.write_to_file(&target)
}
#[allow(dead_code)]
#[cfg(feature = "images")]
pub fn write_image_to_file(image: &NoiseImage, filename: &str) {
use std::{fs, path::Path};
let target = Path::new("example_images/").join(Path::new(filename));
fs::create_dir_all(target.clone().parent().expect("No parent directory found."))
.expect("Failed to create directories.");
image.write_to_file(&target)
}
#[allow(dead_code)]
fn main() {
println!("This is not an example")
}