diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 79 |
1 files changed, 42 insertions, 37 deletions
diff --git a/src/main.rs b/src/main.rs index 5acfbd1..0f8a07e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,8 @@ mod image; use std::{println, format}; +use perlin::MixInImage; + use crate::perlin::Perlin; use crate::vec3::{Vec3,Point3, Color}; use crate::image::Image; @@ -85,55 +87,58 @@ fn sample(h: f64, l: f64) -> Color { }.hsl_to_rgb() } +fn main() { + // params + let height = 512; + let width = 512; + let scale = 1.0; + let turb_depth = 15; + let dsw_factor = 1.5; + let mixin_factor = 0.015; + let mixin_strength = 0.3; + let mixin_image = MixInImage::from_bmp(&include_bytes!("../mixin.bmp").to_vec()); + //let palette = GradientPalette{start: hex_color("0000ff"), end: hex_color("ff0000")}; + //let palette = IdenPalette{}; + let palette = FirePalette{}; + + let hue_perlin = Perlin::new(); + //let light_perlin = Perlin::new(); + let mut image = Image::new(width, height); + for x in 0..width { + for y in 0..height { + let hue_noise = hue_perlin.turb_dsw_mixin(&Point3{x: (x as f64 / width as f64) * scale, y: (y as f64 / height as f64) * scale, z: 0.0}, turb_depth, dsw_factor, &mixin_image, mixin_factor, mixin_strength); + //let light_noise = light_perlin.turb_dsw(&Point3{x: (x as f64 / width as f64) * scale, y: (y as f64 / height as f64) * scale, z: 0.0}, 7); + //image.set(x, y, &sample(hue_noise, light_noise)).unwrap(); + //image.set(x, y, &Color{x: hue_noise, y: hue_noise, z: hue_noise}).unwrap(); + image.set(x, y, &palette.sample(hue_noise)).unwrap(); + } + } + image.write(&mut std::io::stdout()); +} + // fn main() { // // params // let height = 512; // let width = 512; +// let frames = 600; // let scale = 1.0; // let turb_depth = 20; // let dsw_factor = 1.5; -// //let palette = GradientPalette{start: hex_color("0000ff"), end: hex_color("ff0000")}; -// //let palette = IdenPalette{}; // let palette = FirePalette{}; // let hue_perlin = Perlin::new(); -// //let light_perlin = Perlin::new(); // let mut image = Image::new(width, height); -// for x in 0..width { -// for y in 0..height { -// let hue_noise = hue_perlin.turb_dsw(&Point3{x: (x as f64 / width as f64) * scale, y: (y as f64 / height as f64) * scale, z: 0.0}, turb_depth, dsw_factor); -// //let light_noise = light_perlin.turb_dsw(&Point3{x: (x as f64 / width as f64) * scale, y: (y as f64 / height as f64) * scale, z: 0.0}, 7); -// //image.set(x, y, &sample(hue_noise, light_noise)).unwrap(); -// //image.set(x, y, &Color{x: hue_noise, y: hue_noise, z: hue_noise}).unwrap(); -// image.set(x, y, &palette.sample(hue_noise)).unwrap(); +// for f in 0..frames { +// for x in 0..width { +// for y in 0..height { +// let hue_noise = hue_perlin.turb_dsw(&Point3{x: (x as f64 / width as f64) * scale, y: (y as f64 / height as f64) * scale, z: (f as f64 / frames as f64) * scale}, turb_depth, dsw_factor); +// image.set(x, y, &palette.sample(hue_noise)).unwrap(); +// } // } +// let path = format!("./anim/{}.ppm", f); +// image.write(&mut std::fs::File::create(path).unwrap()); + +// println!("Finished frame {} of {}!", f, frames); // } -// image.write(&mut std::io::stdout()); // } -fn main() { - // params - let height = 512; - let width = 512; - let frames = 600; - let scale = 1.0; - let turb_depth = 20; - let dsw_factor = 1.5; - let palette = FirePalette{}; - - let hue_perlin = Perlin::new(); - let mut image = Image::new(width, height); - for f in 0..frames { - for x in 0..width { - for y in 0..height { - let hue_noise = hue_perlin.turb_dsw(&Point3{x: (x as f64 / width as f64) * scale, y: (y as f64 / height as f64) * scale, z: (f as f64 / frames as f64) * scale}, turb_depth, dsw_factor); - image.set(x, y, &palette.sample(hue_noise)).unwrap(); - } - } - let path = format!("./anim/{}.ppm", f); - image.write(&mut std::fs::File::create(path).unwrap()); - - println!("Finished frame {} of {}!", f, frames); - } -} - |