use std::process::Command;
use anyhow::Context;
use tempfile::TempDir;
use super::apply_effect;
pub fn apply_big_sur_corner_effect(time_codes: &[u128], tempdir: &TempDir) {
let radius = 13;
apply_effect(
time_codes,
tempdir,
Box::new(move |file| {
let e = Command::new("convert")
.arg(file.to_str().unwrap())
.arg("(")
.args(["+clone", "-alpha", "extract"])
.args([
"-draw",
&format!(
"fill black polygon 0,0 0,{r} {r},0 fill white circle {r},{r} {r},0",
r = radius
),
])
.args(["(", "+clone", "-flip", ")"])
.args(["-compose", "Multiply", "-composite"])
.args(["(", "+clone", "-flop", ")"])
.args(["-compose", "Multiply", "-composite"])
.arg(")")
.args(["-alpha", "off", "-compose", "CopyOpacity", "-composite"])
.arg(file.to_str().unwrap())
.output()
.context("Cannot apply corner decor effect")?;
if !e.status.success() {
anyhow::bail!("{}", String::from_utf8_lossy(&e.stderr))
} else {
Ok(())
}
}),
)
}