#2817: Closed fits short tangent lists like mask.setClosed

This commit is contained in:
arnav-hiwarkar committed 2026-11-12 18:24:01 +05:30
1 parent d7011a36b8
commit 0ccfd669fb
2 files changed
+21

No files matched your search

+2
View File
@@ -120,6 +120,8 @@ pub(super) fn toggle_closed(s: &mut Session, _: &Value) -> Result<Value> {
if path.closed == closed {
continue;
}
// As `mask.setClosed`: a path read from a file may have fewer tangents than vertices (#1250).
path.fit_tangents();
path.closed = closed;
if roto {
super::roto_smooth(&mut path);
+19
View File
@@ -527,6 +527,25 @@ fn toggle_closed_recomputes_roto_bezier_tangents() {
assert_eq!(path(&s), closed, "reclosing restores the closed RotoBezier tangents");
}
#[test]
fn toggle_closed_fits_short_tangent_lists_like_set_closed() {
let mut s = comp();
let lid = s.execute("layer.newSolid", json!({})).unwrap()["layer"].as_u64().unwrap();
let uid = s.execute("mask.new", json!({"layer": lid, "vertices": [[0, 0], [100, 0], [100, 100]], "closed": true})).unwrap()["mask"].as_u64().unwrap();
let cid = s.active_comp_id().unwrap();
let layer_mut = std::sync::Arc::make_mut(&mut s.project).comp_mut(cid).unwrap().layer_mut(LayerId(lid)).unwrap();
let prop = layer_mut.props.find_group_mut(uid).unwrap().get_mut("path").unwrap();
let KV::Path(path) = &mut prop.value else { panic!("not a path") };
// A file can store fewer tangents than vertices (#1250).
path.in_tangents.clear();
path.out_tangents.truncate(1);
s.state.selected_props = vec![(LayerId(lid), uid)];
s.execute("path.toggleClosed", json!({})).unwrap();
let path = layer(&s, lid).props.find_group(uid).unwrap().get("path").unwrap().value.as_path().unwrap().clone();
assert!(!path.closed);
assert_eq!((path.in_tangents.len(), path.out_tangents.len()), (3, 3));
}
#[test]
fn toggle_closed_edits_layer_time_and_roundtrips() {
use effectcraft_keyframe::Keyframe;