geefr-ppm 0.2.0

A library for creating PPM files
Documentation

#Geefr's PPM lib

This crate provides a PPM writer, originally written for the 'ray tracing in a weekend' series.

Currently supports files in 'P3' format, and max pixel value of 255 (u8). No limits on width/height.

#Reading a PPM

use geefr_ppm::Ppm;
// Load from file
let ppm = Ppm::read(String::from("foo.ppm")).expect("Failed to load PPM");

// Get a pixel
// origin is top-left
let (r,g,b) = ppm.get_pixel(x, y);

#Creating a PPM

use geefr_ppm::Ppm;

// Create a ppm
let mut ppm = Ppm::new(width, height);

// Set a pixel
// origin is top-left
// r, g, b are 0-255 (u8)
ppm.set_pixel(x, y, r, g, b);

// Save to a file
ppm.write(String::from("foo.ppm")).expect("Failed to save PPM");