A simple Rust crate for creating pixel art images with the image crate. Supports additional functionality for fetching pixel neighbours.
use pixel_art::canvas::Canvas;
//Instantiate image. First parameter is the size of each pixel. Second is the resolution of the image. 800 = 800x800
let mut img: Canvas = Canvas::new(10, 800);
//Draw a pixel, according to coordinates and RGB values.
img.draw_pixel(2, 3, [255, 2, 2]);
//Get pixel neighbour coordinates in tuple arrays.
img.get_neighbours_all(x, y) -> //All neighbours.
img.get_neighbours_adjascent(x, y) -> //All directly adjascent neighbours.
img.get_neighbours_diagonal(x, y) -> //All diagonally adjascent neighbours.
img.get_neighbours_direction(x, y, Direction) -> //All neighbours in a certain direction: Up, Down, Left, Right
img.save_image(path, ImageFormat); // Save image.use pixel_art::canvas::Canvas;
use pixel_art::turtle::Turtle;
let mut img: Canvas = Canvas::new(1, 1000);
//Create a turtle that draws green pixels beginning at the center of the canvas, draws 6 pixels every step
let mut turtle: Turtle = Turtle::new([0, 255, 0] (1000/2, 1000/2), 6);
turtle.step(); //Move and draw
turtle.draw(); //Draw, but don't move
turtle.turn(90.0); //Turn 90 degrees right
turtle.draw_points(&mut img); // Draw the points that the turtle has accumulated to the given canvas
img.save_image("test.png"); // Save the image