Clipboard: keyframe text has the source's pixel aspect (#1908)

This commit is contained in:
tylerjenningsw
2026-10-20 08:52:55 -04:00
parent 22ddf7bb99
commit 47093d997a
2 changed files with 27 additions and 2 deletions
+14 -2
View File
@@ -4,7 +4,7 @@
//! (frame number in comp time, then the value) and static ones as a single row with no frame.
//! Easing and tangents aren't part of the format; EffectCraft's own paste keeps them.
use effectcraft_project::{AutoOrient, Comp, Layer, LayerId, Project, Uid};
use effectcraft_project::{AutoOrient, Comp, ItemKind, Layer, LayerId, LayerSource, Project, Uid};
use crate::KeyRef;
@@ -71,13 +71,25 @@ pub(crate) fn text(project: &Project, comp: &Comp, keys: &[KeyRef], statics: &[(
if blocks.is_empty() {
return None;
}
// Layers without a source of their own (text, shapes, cameras) take the comp's size and
// pixel aspect.
let (w, h) = match effectcraft_render::eval::source_size(project, layer) {
(0, 0) => (comp.width, comp.height),
size => size,
};
let par = match layer.source {
LayerSource::Footage { item } | LayerSource::Solid { item } | LayerSource::Comp { item } => match project.item(item).map(|i| &i.kind) {
Some(ItemKind::Footage(f)) => f.pixel_aspect,
Some(ItemKind::Solid(s)) => s.pixel_aspect,
Some(ItemKind::Comp(c)) => c.pixel_aspect,
_ => comp.pixel_aspect,
},
_ => comp.pixel_aspect,
};
Some(format!(
"Adobe After Effects 8.0 Keyframe Data\n\n\tUnits Per Second\t{}\n\tSource Width\t{w}\n\tSource Height\t{h}\n\tSource Pixel Aspect Ratio\t1\n\tComp Pixel Aspect Ratio\t{}\n\n{blocks}End of Keyframe Data\n",
"Adobe After Effects 8.0 Keyframe Data\n\n\tUnits Per Second\t{}\n\tSource Width\t{w}\n\tSource Height\t{h}\n\tSource Pixel Aspect Ratio\t{}\n\tComp Pixel Aspect Ratio\t{}\n\n{blocks}End of Keyframe Data\n",
num(fps),
num(par),
num(comp.pixel_aspect)
))
}
+13
View File
@@ -158,6 +158,19 @@ fn a_2d_layer_writes_the_z_it_shows() {
assert!(text.contains("Transform\tScale\n\tFrame\tX percent\tY percent\tZ percent\n\t0\t50\t60\t100\n"), "{text}");
}
#[test]
fn the_header_has_the_source_pixel_aspect() {
let mut s = Session::default();
s.execute("comp.new", json!({"width": 1920, "height": 1080, "frameRate": 24, "pixelAspect": 1.2})).unwrap();
let solid = LayerId(s.execute("layer.newSolid", json!({"width": 200, "height": 100, "pixelAspect": 1.5})).unwrap()["layer"].as_u64().unwrap());
let text = copy_transform(&mut s, solid);
assert!(text.contains("\tSource Pixel Aspect Ratio\t1.5\n\tComp Pixel Aspect Ratio\t1.2\n"), "{text}");
// A text layer has no source of its own: the comp's.
let t = LayerId(s.execute("layer.newText", json!({"text": "Hi"})).unwrap()["layer"].as_u64().unwrap());
let text = copy_transform(&mut s, t);
assert!(text.contains("\tSource Width\t1920\n\tSource Height\t1080\n\tSource Pixel Aspect Ratio\t1.2\n"), "{text}");
}
#[test]
fn keys_from_two_layers_have_no_text() {
let (mut s, a) = session();