further improvements on drawing basic function
All checks were successful
CI / Rust project (push) Successful in 1m7s

This commit is contained in:
fabolous005 2023-11-26 16:41:11 +01:00
parent 05e41f9540
commit d2c5e120b4
2 changed files with 8 additions and 10 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 810 KiB

After

Width:  |  Height:  |  Size: 714 KiB

View File

@ -1,3 +1,5 @@
#![allow(dead_code)]
use rand::Rng; use rand::Rng;
use image::Rgb; use image::Rgb;
use image::RgbImage; use image::RgbImage;
@ -5,12 +7,8 @@ use image::ImageBuffer;
fn main() { fn main() {
// let mut args = vec![]; let width = 6500;
// for arg in env::args() { let height = 6500;
// args.push(arg);
// }
let width = 7000;
let height = 7000;
let mut img = get_image(width, height); let mut img = get_image(width, height);
// let mut colors= vec![]; // let mut colors= vec![];
@ -18,8 +16,8 @@ fn main() {
let mut points = vec![]; let mut points = vec![];
for i in 0..=1000 { for i in 0..=1000 {
points.push(i as f64 / 1000.0); points.push(i as f64 / 1000.0);
points.push(-(i as f64 / 1000.0));
} }
// println!("{points:?}");
// funktion = f(x) = 3x^2 // funktion = f(x) = 3x^2
// ableitungsquotient = 6a // ableitungsquotient = 6a
@ -31,7 +29,7 @@ fn main() {
// 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, (get_point(point as i32) * 1000.0).round() as u32, Rgb(color));
img.put_pixel( img.put_pixel(
(point * 1000.0_f64).round() as u32 + (width / 2), (point * 1000.0_f64).round() as u32 + (width / 2),
(get_point(point as i32) * 1000.0).round() as u32 + (height / 2), (get_point(point) * 1000.0).round() as u32 + (height / 2),
Rgb([255,255,255]) Rgb([255,255,255])
); );
} }
@ -45,8 +43,8 @@ fn get_pitch_quotient() -> u32 {
6 6
} }
fn get_point(x: i32) -> f64 { fn get_point(x: f64) -> f64 {
(3 * x.pow(2)) as f64 3.0 * x.powf(2.0)
} }