Initial commit

This commit is contained in:
fabolous005 2023-11-23 23:23:29 +01:00
parent 0ead9b554d
commit 942a5f7d33
3 changed files with 68 additions and 0 deletions

12
Cargo.toml Normal file
View File

@ -0,0 +1,12 @@
[package]
name = "incfunc"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
image = "0.24.7"
footile = "0.7.0"
pix = "0.13.3"
imageproc = "0.23.0"

BIN
grid_image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

56
src/main.rs Normal file
View File

@ -0,0 +1,56 @@
use image::{RgbImage, Rgb};
use pix::{matte::Matte8, Raster};
use footile::{FillRule, Path2D, Plotter};
use image::{ImageBuffer};
use imageproc::drawing::draw_line_segment_mut;
fn main() {
let mut img = RgbImage::new(2000, 2000);
for x in 15..=17 {
for y in 8..24 {
img.put_pixel(x, y, Rgb([255, 0, 0]));
img.put_pixel(y, x, Rgb([255, 0, 0]));
}
}
let fish = Path2D::default()
.relative()
.pen_width(3.0)
.move_to(112.0, 24.0)
.line_to(-32.0, 24.0)
.cubic_to(-96.0, -48.0, -96.0, 80.0, 0.0, 32.0)
.line_to(32.0, 24.0)
.line_to(-16.0, -40.0)
.close()
.finish();
let raster = Raster::with_clear(128, 128);
let mut p = Plotter::new(raster);
p.fill(FillRule::NonZero, &fish, Matte8::new(255));
let width = 2000;
let height = 2000;
let mut img: ImageBuffer<Rgb<u16>, Vec<u16>> = ImageBuffer::new(width, height);
// Define grid parameters
let grid_spacing = 50;
let grid_color = Rgb([0, 0, 0]); // Black color
// Draw vertical grid lines
for x in (0..width).step_by(grid_spacing) {
draw_line_segment_mut(&mut img, (x as f32, 0.0), (x as f32, height as f32), grid_color);
}
// Draw horizontal grid lines
for y in (0..height).step_by(grid_spacing) {
draw_line_segment_mut(&mut img, (0.0, y as f32), (width as f32, y as f32), grid_color);
}
// Save the image
// img.save_with_format("grid_image.png", image::ImageFormat::Jpeg).expect("Failed to save image");
img.save("grid_image.png").expect("Failed to save image");
}