2022-11-08 18:17:06 +00:00
|
|
|
use cowgen::*;
|
|
|
|
use std::{
|
|
|
|
fs::{self, File},
|
|
|
|
io::Write,
|
|
|
|
};
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_overlay_text_and_image() {
|
|
|
|
println!("{}", std::env::current_dir().unwrap().to_str().unwrap());
|
2022-11-08 22:20:44 +00:00
|
|
|
let out = Generate::new(
|
2022-11-08 18:17:06 +00:00
|
|
|
include_bytes!("assets/cow.png").to_vec(),
|
|
|
|
vec![
|
|
|
|
Element::new(
|
|
|
|
Media::Text(Text::new(
|
|
|
|
"Hello",
|
|
|
|
"tests/assets/OpenSans-ExtraBold.ttf",
|
|
|
|
20.0,
|
|
|
|
(0, 0, 0, 128),
|
|
|
|
)),
|
|
|
|
(0, 0),
|
|
|
|
(64, 64),
|
|
|
|
),
|
|
|
|
Element::new(
|
|
|
|
Media::Image(include_bytes!("assets/mariah.jpg").to_vec()),
|
|
|
|
(400, 400),
|
|
|
|
(800, 200),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
.unwrap()
|
|
|
|
.produce()
|
|
|
|
.unwrap();
|
|
|
|
let mut f = File::create("tests/out/one.png").unwrap();
|
|
|
|
f.write_all(&out).unwrap();
|
|
|
|
f.flush().unwrap();
|
|
|
|
|
|
|
|
let actual = fs::read("tests/out/one.png").unwrap();
|
|
|
|
let expected = include_bytes!("expected/one.png").to_vec();
|
|
|
|
assert_eq!(expected, actual);
|
|
|
|
}
|