49 lines
876 B
Rust
49 lines
876 B
Rust
#[macro_use]
|
|
extern crate justerror;
|
|
|
|
mod tga;
|
|
|
|
use tga::*;
|
|
|
|
const WHITE: TGAColor = TGAColor {
|
|
bgra: [255, 255, 255, 255],
|
|
};
|
|
|
|
const GREEN: TGAColor = TGAColor {
|
|
bgra: [0, 255, 0, 255],
|
|
};
|
|
|
|
const RED: TGAColor = TGAColor {
|
|
bgra: [0, 0, 255, 255],
|
|
};
|
|
|
|
const BLUE: TGAColor = TGAColor {
|
|
bgra: [255, 128, 64, 255],
|
|
};
|
|
|
|
const YELLOW: TGAColor = TGAColor {
|
|
bgra: [0, 200, 255, 255],
|
|
};
|
|
|
|
fn main() {
|
|
let w = 64;
|
|
let h = 64;
|
|
let mut framebuffer = TGAImage::new(w, h, TGAFormat::RGB);
|
|
|
|
let ax = 7;
|
|
let ay = 3;
|
|
let bx = 12;
|
|
let by = 37;
|
|
let cx = 62;
|
|
let cy = 53;
|
|
|
|
framebuffer.set(ax, ay, &WHITE);
|
|
framebuffer.set(bx, by, &WHITE);
|
|
framebuffer.set(cx, cy, &WHITE);
|
|
|
|
framebuffer
|
|
.write_file("framebuffer.tga", true, true)
|
|
.unwrap();
|
|
|
|
let new = TGAImage::from_file("framebuffer.tga").unwrap();
|
|
}
|