Files
craft-libs/crates/pptx/src/maps.rs
Dylan M. TaylorandJordi Altayó d70adc01fb craft-pptx: transitions and animations (from DeckCraft) (#1067)
* Add craft-drawingml: units, colours, preset shapes, custom geometry and text warps

The parts of DrawingML that need no document model, moved from DeckCraft
(60f91f78): crates/color, crates/geom (preset, warp, Xfrm and the EMU
conversions) and crates/pptx/src/custgeom.rs with CustomPath from
crates/model.

The code is unchanged except that custgeom reads craft-xml trees and writes
to a craft-xml Writer instead of DeckCraft's own XML helper, and matches
elements by local name. The 59 tests of the moved code come with it; six
more cover the custom geometry limits.

* drawingml: evaluate a custom geometry's guide lists once per coordinate space

read_cust_geom rebuilt Guides and evaluated avLst and gdLst again for every
path: up to 1,000 paths times up to 10,000 guides, each name copied and
hashed.

Guides are now cached per path coordinate space (w, h). At most 16 spaces
and 4 MiB of guide names are kept per geometry; paths in further spaces are
left out. The first space is always kept, and a geometry without guides is
not capped.

Ported from storytold/deckcraft#1789. A list counts as having guides only
when it has gd children, as that PR's review asked.

* drawingml: the model types for fills, lines, text, tables, charts and diagrams

Moved from DeckCraft (60f91f78) crates/model/src: style.rs, text.rs,
table.rs, chart.rs, numfmt.rs and trendline.rs, plus Diagram, DiagramNode
and the MediaId and SlideId newtypes from lib.rs.

The files are unchanged except that deckcraft_color:: is crate::color:: and
Fill and TableBorder allow clippy::large_enum_variant. Their 60 tests come
with them. Readers and writers follow.

* drawingml: the theme model (colour, font and format schemes)

Moved from DeckCraft crates/model/src/theme.rs at 60f91f78: FontSet, ScriptFont, FontScheme,
FormatScheme, Theme and default_format. The app's theme gallery, its variants and its own default
theme stay in the app. Theme::default() is a plain theme built in place, so nothing here depends
on a gallery.

* drawingml: readers and writers for fills, lines, text, charts, themes, table styles and diagrams

Moved from DeckCraft crates/pptx/src at 60f91f78: read/dml.rs, write/dml.rs, read/chart.rs,
read/chartex.rs, write/chart.rs, read/theme.rs, write/theme.rs, tables.rs and dgm.rs, onto
craft-xml. Package lookups (Imp, Part, Exp, Out) are the caller's part::Source and part::Sink.
The chart frame budget and kept-part capture stay with the presentation reader.

* drawingml: what WordCraft and GridCraft read that DeckCraft's copy did not

Every ST_PresetColorVal name has its colour, in any case and with the dk/lt/med abbreviations;
a sysClr without lastClr takes the usual value of its name; a Strict percentage (50%) reads
anywhere a percentage does; a chart series keeps its c:f formulas and the writer uses them.

* craft-drawingml: extra named theme colours and explicit tint rows

Ported from the format part of storytold/deckcraft#1746 by @jagjordi: ColorScheme::{extra, tints,
computed_tints}, ExtraColor, GalleryVariant, variants_of, and the a:clrScheme extension that
keeps them in a file.

* drawingml xmlx: copy only used, bounded namespace declarations onto kept fragments and mc branches

From storytold/deckcraft#1740 (988a4920), which landed after the extraction commit 60f91f78.

* Add craft-pptx: the PresentationML model (from DeckCraft)

Presentation, masters, layouts, slides, shapes, placeholders, media,
comments, sections, show settings, properties, embedded fonts, kept parts
and drawing guides from DeckCraft's crates/model/src/lib.rs, and
transitions and animations from anim.rs. The DrawingML types come from
craft-drawingml. The placeholder matching from DeckCraft's resolve.rs
moves as placeholder::parents, without the rest of resolve.

Presentation::default() is now an empty 16:9 deck with no masters; the
starting deck stays with the application.

* craft-pptx: the reader (from DeckCraft), on craft-opc and craft-drawingml

DeckCraft's crates/pptx reader (read.rs, read/shapes.rs and the chart
frame code of read/chart.rs) moved onto craft-opc's Package and
craft-xml trees, with the DrawingML readers of craft-drawingml behind a
part::Source over the import state. What DeckCraft took from its own
defaults (a master for a file without one, the theme of a master that
names none) comes from a caller-supplied Defaults; Plain is the neutral
one. Placeholder geometry inheritance uses placeholder::parents.

Transitions, animations, notes and comments follow in later changes.

* craft-pptx: drop DeckCraft issue numbers from reader comments

* craft-pptx: link the package budgets from the tag budget's doc

* craft-pptx: the writer (from DeckCraft)

DeckCraft's crates/pptx writer (write.rs, write/shapes.rs and the kept
chart parts of write/chart.rs) moved onto craft-opc's PackageOut and
craft-xml's Writer, with craft-drawingml's DrawingML writers behind a
part::Sink over the export state. What DeckCraft took from its own
defaults (a master for a deck without one, master and default text
styles, its name in docProps/app.xml and in table style names) comes
from Defaults. export and export_as take the defaults.

Transitions, animations, notes slides and comments follow in later
changes.

* craft-pptx: transitions and animations (from DeckCraft)

DeckCraft's read/timing.rs, write/timing.rs and maps.rs on craft-xml:
p:transition with the PowerPoint 2010+ effects, and p:timing flattened
into anim::Animation on reading and built back on writing, with the
media settings of the timing tree.

---------

Co-authored-by: Jordi Altayó <jordiag@kth.se>
2026-11-11 21:59:03 -05:00

454 lines
19 KiB
Rust

//! Mappings between our transition / animation ids and PresentationML elements and preset
//! numbers, shared by the reader and the writer.
use crate::anim::{ANIMATIONS, AnimClass};
use craft_xml::{El, Writer, value};
/// (our kind, namespace prefix, element) for transitions that map one-to-one.
const SIMPLE: &[(&str, &str, &str)] =
&[("dissolve", "p", "dissolve"), ("random", "p", "random"), ("honeycomb", "p14", "honeycomb"), ("flash", "p14", "flash")];
/// Read a transition effect element → (kind, option). `None` for effects we don't model.
pub fn transition_from_xml(e: &El) -> Option<(String, String)> {
let (k, o) = transition_from_xml_raw(e)?;
// Kinds without options keep none.
let has_opts = crate::anim::TRANSITIONS.iter().find(|t| t.0 == k).is_none_or(|t| !t.4.is_empty());
Some((k, if has_opts { o } else { String::new() }))
}
/// Preset transitions (`p15:prstTrans`) whose "Left" option PowerPoint writes with `invX="1"`
/// (the others write it for "Right"), as observed on PowerPoint's own files.
const INVX_LEFT: &[&str] = &["wind", "airplane", "origami"];
fn transition_from_xml_raw(e: &El) -> Option<(String, String)> {
// Defaults are what PowerPoint leaves out: e.g. it writes Push Left as `<p:push/>`.
let dir = |d: &str| e.attr_local("dir").unwrap_or(d).to_string();
let k = |s: &str| s.to_string();
Some(match e.local() {
"fade" => (k("fade"), if e.attr_local("thruBlk").and_then(value::to_bool) == Some(true) { k("throughBlack") } else { k("smoothly") }),
"cut" => (k("cut"), if e.attr_local("thruBlk").and_then(value::to_bool) == Some(true) { k("throughBlack") } else { String::new() }),
"push" => (k("push"), dir("l")),
"wipe" => (k("wipe"), dir("l")),
// Diagonal wipes.
"strips" => (k("wipe"), dir("lu")),
"split" => {
let o = e.attr_local("orient").unwrap_or("horz");
let d = e.attr_local("dir").unwrap_or("out");
(k("split"), format!("{o}{}", if d == "in" { "In" } else { "Out" }))
}
"randomBar" => (k("randomBar"), dir("horz")),
"circle" => (k("shape"), k("circle")),
"diamond" => (k("shape"), k("diamond")),
"plus" => (k("shape"), k("plus")),
// Shape In / Out (the slide zooming in a box).
"zoom" => (k("shape"), if e.attr_local("dir") == Some("in") { k("in") } else { k("out") }),
// The Zoom transition, and its Zoom and Rotate option.
"warp" => (k("zoom"), if e.attr_local("dir") == Some("in") { k("in") } else { k("out") }),
"newsflash" => (k("zoom"), k("rotate")),
"pull" => (k("uncover"), dir("l")),
"cover" => (k("cover"), dir("l")),
"checker" => (k("checker"), dir("horz")),
"blinds" => (k("blinds"), dir("horz")),
"comb" => (k("comb"), dir("horz")),
"wheel" => (k("clock"), k("clockwise")),
"wheelReverse" => (k("clock"), k("counterClockwise")),
"wedge" => (k("clock"), k("wedge")),
"vortex" => (k("vortex"), dir("l")),
"switch" => (k("switch"), dir("r")),
"flip" => (k("flip"), dir("r")),
"ripple" => (k("ripple"), dir("center")),
"doors" => (k("doors"), dir("horz")),
"window" => (k("window"), dir("horz")),
"ferris" => (k("ferris"), dir("l")),
"gallery" => (k("gallery"), dir("l")),
"conveyor" => (k("conveyor"), dir("l")),
"pan" => (k("pan"), dir("l")),
"glitter" => {
let d = dir("l");
if e.attr_local("pattern") == Some("hexagon") { (k("glitter"), format!("hex{}", d.to_ascii_uppercase())) } else { (k("glitter"), d) }
}
"shred" => {
// `crush` is what DeckCraft wrote before it knew PowerPoint's `rectangle`.
let particles = matches!(e.attr_local("pattern"), Some("rectangle" | "crush"));
let out = e.attr_local("dir") == Some("out");
(k("shred"), format!("{}{}", if particles { "particles" } else { "strips" }, if out { "Out" } else { "In" }))
}
"reveal" => {
let black = e.attr_local("thruBlk").and_then(value::to_bool) == Some(true);
let right = e.attr_local("dir") == Some("r");
(k("reveal"), format!("{}{}", if black { "black" } else { "smoothly" }, if right { "Right" } else { "Left" }))
}
"flythrough" => {
let out = e.attr_local("dir") == Some("out");
let b = e.attr_local("hasBounce").and_then(value::to_bool) == Some(true);
(k("flythrough"), format!("{}{}", if out { "out" } else { "in" }, if b { "Bounce" } else { "" }))
}
"prism" => {
let content = e.attr_local("isContent").and_then(value::to_bool) == Some(true);
let inv = e.attr_local("isInverted").and_then(value::to_bool) == Some(true);
let kind = match (content, inv) {
(false, false) => "cube",
(false, true) => "box",
(true, false) => "rotate",
(true, true) => "orbit",
};
(k(kind), dir("l"))
}
"prstTrans" => {
let prst = e.attr_local("prst").unwrap_or("fallOver");
let inv = e.attr_local("invX").and_then(value::to_bool) == Some(true);
if prst == "pageCurlSingle" {
return Some((k("pageCurlDouble"), if inv { k("singleR") } else { k("singleL") }));
}
let known = crate::anim::TRANSITIONS.iter().any(|t| t.0 == prst);
if !known {
return None;
}
let left = if INVX_LEFT.contains(&prst) { inv } else { !inv };
(k(prst), if left { k("l") } else { k("r") })
}
"morph" => (
k("morph"),
match e.attr_local("option") {
Some("byWord") => k("words"),
Some("byChar") => k("characters"),
_ => k("objects"),
},
),
other => (k(SIMPLE.iter().find(|s| s.2 == other)?.0), String::new()),
})
}
/// Write the effect element for a transition. Returns the namespace prefix it needs
/// (`p`, `p14`, `p15`, `p159`), or `None` when the kind is unknown.
pub fn transition_to_xml(w: &mut Writer, kind: &str, option: &str) -> Option<&'static str> {
let lr = |d: &'static str| match option {
"l" | "r" => option.to_string(),
_ => d.to_string(),
};
let lrud = |d: &'static str| match option {
"l" | "r" | "u" | "d" => option.to_string(),
_ => d.to_string(),
};
let hv = |d: &'static str| match option {
"horz" | "vert" => option.to_string(),
_ => d.to_string(),
};
let eight = |d: &'static str| match option {
"l" | "r" | "u" | "d" | "lu" | "ru" | "ld" | "rd" => option.to_string(),
_ => d.to_string(),
};
match kind {
"fade" => w.tag("p:fade").attr_opt("thruBlk", (option == "throughBlack").then_some(1)).empty(),
"cut" => w.tag("p:cut").attr_opt("thruBlk", (option == "throughBlack").then_some(1)).empty(),
"push" => w.tag("p:push").attr("dir", lrud("u")).empty(),
"wipe" => match option {
"lu" | "ru" | "ld" | "rd" => w.tag("p:strips").attr("dir", option).empty(),
_ => w.tag("p:wipe").attr("dir", lrud("r")).empty(),
},
"split" => {
let (o, d) = match option {
"vertIn" => ("vert", "in"),
"vertOut" => ("vert", "out"),
"horzIn" => ("horz", "in"),
_ => ("horz", "out"),
};
w.tag("p:split").attr("orient", o).attr("dir", d).empty();
}
"randomBar" => w.tag("p:randomBar").attr("dir", hv("vert")).empty(),
"shape" => match option {
"diamond" => w.empty("p:diamond", &[]),
"plus" => w.empty("p:plus", &[]),
"in" | "out" => w.tag("p:zoom").attr("dir", option).empty(),
_ => w.empty("p:circle", &[]),
},
"zoom" => match option {
"rotate" => w.empty("p:newsflash", &[]),
_ => {
w.tag("p14:warp").attr("dir", if option == "out" { "out" } else { "in" }).empty();
return Some("p14");
}
},
"uncover" => w.tag("p:pull").attr("dir", eight("l")).empty(),
"cover" => w.tag("p:cover").attr("dir", eight("l")).empty(),
"checker" => w.tag("p:checker").attr("dir", hv("horz")).empty(),
"blinds" => w.tag("p:blinds").attr("dir", hv("horz")).empty(),
"comb" => w.tag("p:comb").attr("dir", hv("horz")).empty(),
"clock" => match option {
"counterClockwise" => {
w.tag("p14:wheelReverse").attr("spokes", 1).empty();
return Some("p14");
}
"wedge" => w.empty("p:wedge", &[]),
_ => w.tag("p:wheel").attr("spokes", 1).empty(),
},
"dissolve" => w.empty("p:dissolve", &[]),
"random" => w.empty("p:random", &[]),
"honeycomb" => {
w.empty("p14:honeycomb", &[]);
return Some("p14");
}
"flash" => {
w.empty("p14:flash", &[]);
return Some("p14");
}
"vortex" => {
w.tag("p14:vortex").attr("dir", lrud("l")).empty();
return Some("p14");
}
"glitter" => {
let hex = option.starts_with("hex");
let d = option.trim_start_matches("hex").to_ascii_lowercase();
let d = if matches!(d.as_str(), "l" | "r" | "u" | "d") { d } else { "l".to_string() };
w.tag("p14:glitter").attr("dir", d).attr_opt("pattern", hex.then_some("hexagon")).empty();
return Some("p14");
}
"switch" | "flip" | "gallery" | "conveyor" | "ferris" => {
let name = match kind {
"switch" => "p14:switch",
"flip" => "p14:flip",
"gallery" => "p14:gallery",
"conveyor" => "p14:conveyor",
_ => "p14:ferris",
};
w.tag(name).attr("dir", lr("l")).empty();
return Some("p14");
}
"ripple" => {
let d = match option {
"lu" | "ru" | "ld" | "rd" => option,
_ => "center",
};
w.tag("p14:ripple").attr("dir", d).empty();
return Some("p14");
}
"doors" | "window" => {
let name = if kind == "doors" { "p14:doors" } else { "p14:window" };
w.tag(name).attr("dir", hv("vert")).empty();
return Some("p14");
}
"pan" => {
w.tag("p14:pan").attr("dir", lrud("d")).empty();
return Some("p14");
}
"shred" => {
let particles = option.starts_with("particles");
w.tag("p14:shred")
.attr("pattern", if particles { "rectangle" } else { "strip" })
.attr("dir", if option.ends_with("Out") { "out" } else { "in" })
.empty();
return Some("p14");
}
"reveal" => {
w.tag("p14:reveal")
.attr_opt("thruBlk", (option.starts_with("black")).then_some(1))
.attr("dir", if option.ends_with("Right") { "r" } else { "l" })
.empty();
return Some("p14");
}
"flythrough" => {
w.tag("p14:flythrough")
.attr("dir", if option.starts_with("out") { "out" } else { "in" })
.attr_opt("hasBounce", (option.ends_with("Bounce")).then_some(1))
.empty();
return Some("p14");
}
"cube" | "box" | "rotate" | "orbit" => {
w.tag("p14:prism")
.attr("dir", lrud("l"))
.attr_opt("isContent", (matches!(kind, "rotate" | "orbit")).then_some(1))
.attr_opt("isInverted", (matches!(kind, "box" | "orbit")).then_some(1))
.empty();
return Some("p14");
}
"pageCurlDouble" if option.starts_with("single") => {
w.tag("p15:prstTrans").attr("prst", "pageCurlSingle").attr_opt("invX", (option == "singleR").then_some(1)).empty();
return Some("p15");
}
"fallOver" | "drape" | "curtains" | "wind" | "prestige" | "fracture" | "crush" | "peelOff" | "pageCurlDouble" | "airplane" | "origami" => {
let inv = if INVX_LEFT.contains(&kind) { option == "l" } else { option == "r" };
w.tag("p15:prstTrans").attr("prst", kind).attr_opt("invX", (inv).then_some(1)).empty();
return Some("p15");
}
"morph" => {
let o = match option {
"words" => "byWord",
"characters" => "byChar",
_ => "byObject",
};
w.tag("p159:morph").attr("option", o).empty();
return Some("p159");
}
_ => return None,
}
Some("p")
}
// ---------------------------------------------------------------------------------------------
// Animations
/// Effect options ↔ preset subtypes.
const SUBTYPES: &[(&str, &[(&str, u32)])] = &[
("fly", DIR8),
("flyOut", DIR8),
("peek", DIR4),
("wipe", DIR4),
("wipeOut", DIR4),
("strips", &[("lu", 9), ("ru", 3), ("ld", 12), ("rd", 6)]),
("split", SPLIT),
("splitOut", SPLIT),
("zoom", INOUT),
("zoomOut", INOUT),
("box", INOUT),
("circle", INOUT),
("diamond", INOUT),
("randomBars", HV),
("randomBarsOut", HV),
("blinds", HV),
("swivel", HV),
("swivelOut", HV),
("blindsOut", HV),
("boxOut", INOUT),
("checkerboardOut", &[("across", 10), ("down", 5)]),
("diamondOut", INOUT),
("peekOut", DIR4),
("stripsOut", &[("lu", 9), ("ru", 3), ("ld", 12), ("rd", 6)]),
("checkerboard", &[("across", 10), ("down", 5)]),
("wheel", WHEEL),
("wheelOut", WHEEL),
("float", &[("u", 0), ("d", 4)]),
("floatOut", &[("u", 0), ("d", 4)]),
(
"shape",
&[("circleIn", 16), ("circleOut", 32), ("boxIn", 16), ("boxOut", 32), ("diamondIn", 16), ("diamondOut", 32), ("plusIn", 16), ("plusOut", 32)],
),
("shapeOut", INOUT_SHAPE),
("lines", &[("down", 4), ("up", 1), ("right", 2), ("left", 8)]),
("arcs", &[("down", 4), ("up", 1), ("right", 2), ("left", 8)]),
("turns", &[("down", 4), ("up", 1), ("right", 2), ("left", 8)]),
];
const DIR8: &[(&str, u32)] = &[("b", 4), ("lb", 12), ("l", 8), ("lt", 9), ("t", 1), ("rt", 3), ("r", 2), ("rb", 6)];
const DIR4: &[(&str, u32)] = &[("b", 4), ("l", 8), ("t", 1), ("r", 2)];
const SPLIT: &[(&str, u32)] = &[("horzIn", 21), ("horzOut", 42), ("vertIn", 26), ("vertOut", 37)];
const INOUT: &[(&str, u32)] = &[("in", 16), ("out", 32)];
const INOUT_SHAPE: &[(&str, u32)] = &[("circleIn", 16), ("circleOut", 32)];
const HV: &[(&str, u32)] = &[("horz", 10), ("vert", 5)];
const WHEEL: &[(&str, u32)] = &[("1", 1), ("2", 2), ("3", 3), ("4", 4), ("8", 8)];
pub fn option_from_subtype(effect: &str, sub: u32) -> String {
SUBTYPES.iter().find(|(e, _)| *e == effect).and_then(|(_, m)| m.iter().find(|(_, s)| *s == sub)).map(|(o, _)| o.to_string()).unwrap_or_default()
}
pub fn subtype_from_option(effect: &str, option: &str) -> Option<u32> {
SUBTYPES.iter().find(|(e, _)| *e == effect).and_then(|(_, m)| m.iter().find(|(o, _)| *o == option)).map(|(_, s)| *s)
}
/// Our effect id for a preset (first match in [`ANIMATIONS`]).
pub fn effect_for_preset(class: AnimClass, preset: u32) -> Option<&'static str> {
ANIMATIONS.iter().find(|a| a.2 == class && a.3 == preset && a.0 != "customPath").map(|a| a.0)
}
/// Effect used for presets we don't know.
pub fn fallback_effect(class: AnimClass) -> &'static str {
match class {
AnimClass::Entrance => "fade",
AnimClass::Exit => "fadeOut",
AnimClass::Emphasis => "pulse",
AnimClass::Path => "customPath",
AnimClass::Media => "play",
}
}
/// The preset id to write for an animation.
pub fn preset_for(a: &crate::Animation) -> u32 {
// Float Down is PowerPoint's preset 47 (Float Up is 42).
if matches!(a.effect.as_str(), "float" | "floatOut") && a.option == "d" {
return 47;
}
if let Some(p) = a.preset_id {
let consistent = match effect_for_preset(a.class, p) {
Some(e) => e == a.effect,
None => a.effect == fallback_effect(a.class),
};
if consistent {
return p;
}
}
match crate::anim::animation_info(&a.effect, a.class) {
Some(info) if info.2 == a.class => info.3,
_ => match a.class {
AnimClass::Entrance | AnimClass::Exit => 10,
AnimClass::Emphasis => 26,
AnimClass::Path => 0,
AnimClass::Media => 1,
},
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::package::parse;
/// These exits, with their directions, fell back to a plain fade (PowerPoint's ids).
#[test]
fn exit_presets_import_as_their_own_effects() {
for (preset, sub, effect, option) in [
(3, 10, "blindsOut", "horz"),
(4, 32, "boxOut", "out"),
(5, 5, "checkerboardOut", "down"),
(8, 16, "diamondOut", "in"),
(12, 4, "peekOut", "b"),
(18, 6, "stripsOut", "rd"),
(37, 0, "sinkDown", ""),
(49, 0, "spinnerOut", ""),
(55, 0, "contract", ""),
] {
let e = effect_for_preset(AnimClass::Exit, preset).expect("known exit");
assert_eq!((e, option_from_subtype(e, sub).as_str()), (effect, option), "preset {preset}");
}
}
#[test]
fn every_transition_kind_round_trips() {
for (kind, _, _, _, opts) in crate::anim::TRANSITIONS {
if *kind == "none" {
continue;
}
let opts: Vec<&str> = if opts.is_empty() { vec![""] } else { opts.to_vec() };
for o in opts {
let mut w = Writer::new();
let ns = transition_to_xml(&mut w, kind, o).unwrap_or_else(|| panic!("no xml for {kind}"));
assert!(!ns.is_empty());
let d = parse(w.as_str().as_bytes()).unwrap();
let (k, opt) = transition_from_xml(&d.root).unwrap_or_else(|| panic!("no read for {kind}"));
assert_eq!(k, *kind, "kind for {kind}/{o}");
if !o.is_empty() {
assert_eq!(opt, o, "option for {kind}");
}
}
}
}
#[test]
fn subtypes() {
assert_eq!(subtype_from_option("fly", "b"), Some(4));
assert_eq!(option_from_subtype("fly", 8), "l");
assert_eq!(option_from_subtype("fade", 0), "");
assert_eq!(effect_for_preset(AnimClass::Entrance, 2), Some("fly"));
assert_eq!(effect_for_preset(AnimClass::Emphasis, 8), Some("spin"));
}
/// PowerPoint's own ids: Darken is 24 and Desaturate 25 (read back from its saved file).
#[test]
fn darken_and_desaturate_use_powerpoints_ids() {
assert_eq!(effect_for_preset(AnimClass::Emphasis, 24), Some("darken"));
assert_eq!(effect_for_preset(AnimClass::Emphasis, 25), Some("desaturate"));
for (effect, id) in [("darken", 24), ("desaturate", 25)] {
let a = crate::Animation { class: AnimClass::Emphasis, effect: effect.into(), ..Default::default() };
assert_eq!(preset_for(&a), id, "{effect}");
}
}
}