mirror of
https://github.com/storytold/effectcraft.git
synced 2026-11-02 14:38:21 -06:00
Merge pull request #555 from LloydNicholson/fix/addsolid-pixel-aspect
# Conflicts: # crates/script/src/tests.rs
This commit is contained in:
@@ -1235,6 +1235,7 @@ LayerCollection.prototype = {
|
||||
if (name !== undefined) p.name = String(name);
|
||||
if (width !== undefined) p.width = Math.round(__num(width, "width"));
|
||||
if (height !== undefined) p.height = Math.round(__num(height, "height"));
|
||||
if (pixelAspect !== undefined) p.pixelAspect = __num(pixelAspect, "pixelAspect");
|
||||
return this.__dur(this.__new(__call("layer.newSolid", p)), duration);
|
||||
},
|
||||
addNull: function (duration) { return this.__dur(this.__new(__call("layer.newNull", { comp: this.__comp })), duration); },
|
||||
|
||||
@@ -592,3 +592,22 @@ fn setting_item_selected_false_preserves_other_project_items() {
|
||||
json!("Keep,Target|[[true,true],[false,true],[false,true],[true,true]]")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn add_solid_keeps_the_requested_pixel_aspect() {
|
||||
let mut s = session();
|
||||
let o = ok(
|
||||
&mut s,
|
||||
r#"
|
||||
var c = app.project.items.addComp("PA", 64, 32, 1, 1, 10);
|
||||
var square = c.layers.addSolid([1, 0, 0], "Square", 16, 16, 1);
|
||||
var wide = c.layers.addSolid([0, 1, 0], "Wide", 16, 16, 2);
|
||||
var inherited = c.layers.addSolid([0, 0, 1], "Inherited", 16, 16);
|
||||
[c.pixelAspect, square.source.pixelAspect, wide.source.pixelAspect, inherited.source.pixelAspect,
|
||||
wide.source.width, wide.source.height]
|
||||
"#,
|
||||
);
|
||||
assert_eq!(o.result, json!([1, 1, 2, 1, 16, 16]));
|
||||
let bad = run_code(&mut s, r#"app.project.items.addComp("Q", 8, 8, 1, 1, 10).layers.addSolid([1, 1, 1], "Bad", 8, 8, 0)"#, "bad.jsx");
|
||||
assert!(bad.error.is_some_and(|e| e.message.contains("pixelAspect")));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user