diff --git a/grid_image.png b/grid_image.png index 20ae223..4da4dfc 100644 Binary files a/grid_image.png and b/grid_image.png differ diff --git a/src/main.rs b/src/main.rs index d15173e..4346cdc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,3 @@ -use std::env; use rand::Rng; use image::Rgb; use image::RgbImage; @@ -10,19 +9,31 @@ fn main() { // for arg in env::args() { // args.push(arg); // } - let mut img = get_image(); + let width = 7000; + let height = 7000; + let mut img = get_image(width, height); - let mut colors= vec![]; - let points = [0.1, 0.2, 0.3, 0.4, 0.5]; + // let mut colors= vec![]; - // function = f(x) = 3x^2 + let mut points = vec![]; + for i in 0..=1000 { + points.push(i as f64 / 1000.0); + } + // println!("{points:?}"); + + // funktion = f(x) = 3x^2 // ableitungsquotient = 6a for point in points { - let color = [generate_random(0, 255), generate_random(0, 255), generate_random(0, 255)]; - colors.push(color); - img.put_pixel((point * 1000.0).round_ties_even() as u32, (get_point(point as i32) * 1000.0).round() as u32, Rgb(color)); + // let color = [generate_random(0, 255), generate_random(0, 255), generate_random(0, 255)]; + // colors.push(color); + // img.put_pixel((point * 1000.0_f64).round() as u32, (get_point(point as i32) * 1000.0).round() as u32, Rgb(color)); + img.put_pixel( + (point * 1000.0_f64).round() as u32 + (width / 2), + (get_point(point as i32) * 1000.0).round() as u32 + (height / 2), + Rgb([255,255,255]) + ); } @@ -45,9 +56,7 @@ fn generate_random(start: u8, end: u8) -> u8 { rng.gen_range(start..=end) } -fn get_image() -> ImageBuffer, Vec> { - let width = 1000; - let height = 1000; +fn get_image(width: u32, height: u32) -> ImageBuffer, Vec> { let mut img = RgbImage::new(width, height); let grid_spacing = 50; let grid_color = Rgb([255, 9, 255]); // Black colo