summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorlamp2023-12-29 23:32:34 +0000
committerlamp2023-12-29 23:32:34 +0000
commiteb8a896865a6f3dbb5e3680c43ae408e29176ae4 (patch)
tree82eeb300be148a987d26aefd6c2c7afb2a92f541 /src/main.rs
parentb3bb54ca9cdcca60adb401fd69278a12d8fd367a (diff)
initial dsw_mixin stuffmain
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs79
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);
- }
-}
-