fix(engine): default transparent to true in queue_frame

This commit is contained in:
Kushagra Kumar committed 2026-10-25 19:51:06 +05:30
1 parent 5d25346547
commit 59b564326e
2 files changed
+26 -8

No files matched your search

+7 -8
View File
@@ -91,14 +91,13 @@ fn queue_frame(s: &mut Session, p: &Value) -> Result<Value> {
it.settings = s.project.render_templates.default_render_settings(TemplateSlot::Still);
it.settings.time_span = TimeSpan::Custom { start: t, end: t + comp.frame_duration() };
it.output = s.project.render_templates.default_output_module(TemplateSlot::Still);
if let Some(transparent) = b_p(p, "transparent") {
if !transparent {
it.output.channels = Channels::Rgb;
} else if it.output.supports_alpha() {
it.output.channels = Channels::Rgba;
} else {
return Err(bad("comp.saveFrameAs", format!("{} doesn't support an alpha channel", it.output.format.label())));
}
let transparent = b_p(p, "transparent").unwrap_or(true);
if !transparent {
it.output.channels = Channels::Rgb;
} else if it.output.supports_alpha() {
it.output.channels = Channels::Rgba;
} else {
return Err(bad("comp.saveFrameAs", format!("{} doesn't support an alpha channel", it.output.format.label())));
}
if let Some(path) = str_p(p, "path") {
it.output.output = path.to_string();
+19
View File
@@ -219,3 +219,22 @@ fn save_frame_as_defaults_to_png_sequence_with_alpha() {
assert_eq!(it.output.name, "PNG Sequence with Alpha");
assert_eq!(it.output.channels, effectcraft_project::render_queue::Channels::Rgba);
}
#[test]
fn save_frame_as_defaults_to_transparent_even_with_rgb_frame_template() {
let mut s = Session::default();
s.execute("comp.new", json!({"name": "Comp", "width": 32, "height": 32, "frameRate": 24, "duration": 1})).unwrap();
// Set Frame Default to an RGB output template ("PNG Sequence")
s.execute_checked("renderQueue.setTemplateDefault", json!({"kind": "outputModule", "slot": "still", "name": "PNG Sequence"})).unwrap();
// Omitting `transparent` must default to true and promote to Channels::Rgba
s.execute_checked("comp.saveFrameAs", json!({"queue": true})).unwrap();
let it = s.project.render_queue.last().unwrap();
assert_eq!(it.output.channels, effectcraft_project::render_queue::Channels::Rgba);
// Explicit `transparent: false` respects the request and stays Channels::Rgb
s.execute_checked("comp.saveFrameAs", json!({"queue": true, "transparent": false})).unwrap();
let it = s.project.render_queue.last().unwrap();
assert_eq!(it.output.channels, effectcraft_project::render_queue::Channels::Rgb);
}