fix compile error and produce first start for basic function
All checks were successful
CI / Rust project (push) Successful in 1m6s
All checks were successful
CI / Rust project (push) Successful in 1m6s
This commit is contained in:
parent
40d962edb1
commit
05e41f9540
BIN
grid_image.png
BIN
grid_image.png
Binary file not shown.
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 810 KiB |
31
src/main.rs
31
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<Rgb<u8>, Vec<u8>> {
|
||||
let width = 1000;
|
||||
let height = 1000;
|
||||
fn get_image(width: u32, height: u32) -> ImageBuffer<Rgb<u8>, Vec<u8>> {
|
||||
let mut img = RgbImage::new(width, height);
|
||||
let grid_spacing = 50;
|
||||
let grid_color = Rgb([255, 9, 255]); // Black colo
|
||||
|
||||
Loading…
Reference in New Issue
Block a user