| Crates.io | geefr-ppm |
| lib.rs | geefr-ppm |
| version | 0.2.0 |
| created_at | 2020-04-18 10:36:28.383776+00 |
| updated_at | 2020-04-18 12:09:29.145326+00 |
| description | A library for creating PPM files |
| homepage | |
| repository | |
| max_upload_size | |
| id | 231458 |
| size | 6,459 |
#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");