further improvements on drawing basic function
All checks were successful
CI / Rust project (push) Successful in 1m7s
All checks were successful
CI / Rust project (push) Successful in 1m7s
This commit is contained in:
parent
05e41f9540
commit
d2c5e120b4
BIN
grid_image.png
BIN
grid_image.png
Binary file not shown.
|
Before Width: | Height: | Size: 810 KiB After Width: | Height: | Size: 714 KiB |
18
src/main.rs
18
src/main.rs
@ -1,3 +1,5 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use rand::Rng;
|
||||
use image::Rgb;
|
||||
use image::RgbImage;
|
||||
@ -5,12 +7,8 @@ use image::ImageBuffer;
|
||||
|
||||
|
||||
fn main() {
|
||||
// let mut args = vec![];
|
||||
// for arg in env::args() {
|
||||
// args.push(arg);
|
||||
// }
|
||||
let width = 7000;
|
||||
let height = 7000;
|
||||
let width = 6500;
|
||||
let height = 6500;
|
||||
let mut img = get_image(width, height);
|
||||
|
||||
// let mut colors= vec![];
|
||||
@ -18,8 +16,8 @@ fn main() {
|
||||
let mut points = vec![];
|
||||
for i in 0..=1000 {
|
||||
points.push(i as f64 / 1000.0);
|
||||
points.push(-(i as f64 / 1000.0));
|
||||
}
|
||||
// println!("{points:?}");
|
||||
|
||||
// funktion = f(x) = 3x^2
|
||||
// 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 + (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])
|
||||
);
|
||||
}
|
||||
@ -45,8 +43,8 @@ fn get_pitch_quotient() -> u32 {
|
||||
6
|
||||
}
|
||||
|
||||
fn get_point(x: i32) -> f64 {
|
||||
(3 * x.pow(2)) as f64
|
||||
fn get_point(x: f64) -> f64 {
|
||||
3.0 * x.powf(2.0)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user