https://github.com/coderarjob/libpix
Do what you want with put-pixel. This Library which provides a 'frame buffer', put-pixel function and ablity to save it to a PPM file
https://github.com/coderarjob/libpix
Last synced: 8 months ago
JSON representation
Do what you want with put-pixel. This Library which provides a 'frame buffer', put-pixel function and ablity to save it to a PPM file
- Host: GitHub
- URL: https://github.com/coderarjob/libpix
- Owner: coderarjob
- License: gpl-3.0
- Created: 2024-06-26T19:56:16.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-09-14T12:54:18.000Z (almost 2 years ago)
- Last Synced: 2024-09-14T23:04:08.971Z (almost 2 years ago)
- Language: Rust
- Homepage:
- Size: 281 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# libpix - A graphics library that's simple
The library provides a frame buffer and simple `put-pixel` and `save-to-file` routines. Thats all
you require to test and play around with graphics.
Simply draw to the frame buffer save to a file then see the output!
It is increasingly becoming difficult to get a simple buffer and start drawing. I do somewhat
understand why this is so - we are not living in DOS times! But still the barrier to start working
with graphics should not be this hard.
This GUI toolkit, this provides just a buffer where one can put pixels then save the buffer to a PPM
file and see the output.
### Why PPM and not any other file format?
Because its a simple image format ([Wikipedia - Netpbm](https://en.wikipedia.org/wiki/Netpbm)) and is supported in Linux.
## Example:

```rust
use libpix::{Canvas, PPMFormats};
const WIDTH: usize = 400;
const HEIGHT: usize = 400;
fn main() {
let mut c = Canvas::new(WIDTH, HEIGHT, PPMFormats::RAW);
for x in 0..WIDTH {
for y in 0..HEIGHT {
if (x ^ y) % 7 == 0 {
c.put_pixel(x, y, 0xFF0000);
}
}
}
c.save_to_file("example.ppm").expect("Could not save image");
}
```
[Other examples](./examples)