This commit is contained in:
+30
-16
@@ -1,18 +1,27 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::env;
|
||||
use clap::Parser;
|
||||
use rand::Rng;
|
||||
use image::Rgb;
|
||||
use image::RgbImage;
|
||||
use image::ImageBuffer;
|
||||
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
#[derive(Parser)]
|
||||
struct Args {
|
||||
/// Optimization level
|
||||
#[arg(short, default_value_t = 3)]
|
||||
opt_level: u8,
|
||||
|
||||
let _num_chunks = args.get(1)
|
||||
.and_then(|arg: &String| arg.parse::<usize>().ok())
|
||||
.unwrap_or(num_cpus::get());
|
||||
/// Number of cores [default: max]
|
||||
#[arg(short, value_name = "CORES")]
|
||||
core: Option<u8>
|
||||
}
|
||||
|
||||
|
||||
fn main() {
|
||||
|
||||
let args = Args::parse();
|
||||
|
||||
let width = 7000;
|
||||
let height = 7000;
|
||||
@@ -24,10 +33,14 @@ fn main() {
|
||||
// points.push(i as f64 / 10000.0);
|
||||
// // points.push(-(i as f64 / 10000.0));
|
||||
// }
|
||||
|
||||
let step = 0.001; // Define the step size
|
||||
|
||||
let mut step = "0.".to_string();
|
||||
for _ in 0..args.opt_level {
|
||||
step.push('0')
|
||||
}
|
||||
step.push('1');
|
||||
let step: f64 = step.parse().unwrap();
|
||||
let mut current_value = 0.0;
|
||||
|
||||
while current_value <= 1.8 {
|
||||
points.push(current_value);
|
||||
current_value += step;
|
||||
@@ -43,16 +56,17 @@ fn main() {
|
||||
];
|
||||
colors.push(color);
|
||||
for point in points {
|
||||
let x = (point * 1000.0_f64).round() as u32;
|
||||
let y = (get_point(point) * 1000.0).round() as u32;
|
||||
// NOTE: convert later to u32 because deviding may change actual value
|
||||
let x = point * 1000.0_f64;
|
||||
let y = get_point(point) * 1000.0;
|
||||
img.put_pixel(
|
||||
x + width / 2,
|
||||
y + height / 2,
|
||||
(width as f64 / 2.0 + x).round() as u32,
|
||||
(height as f64 / 2.0 + y) as u32,
|
||||
Rgb(color)
|
||||
);
|
||||
img.put_pixel(
|
||||
x + width / 2 - x * 2,
|
||||
y + height / 2,
|
||||
(width as f64 / 2.0 - x).round() as u32,
|
||||
(height as f64 / 2.0 + y).round() as u32,
|
||||
Rgb(color)
|
||||
);
|
||||
|
||||
@@ -81,7 +95,7 @@ fn generate_random(start: u8, end: u8) -> u8 {
|
||||
|
||||
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_spacing = 100;
|
||||
let grid_color = Rgb([255,9,255]);
|
||||
|
||||
for x in (0..width).step_by(grid_spacing) {
|
||||
|
||||
Reference in New Issue
Block a user