Roto Brush: test that a stroke corrects earlier ones through the commands (#1646)

Green, Alt (red) over part of the object, then green there again, as the
Layer panel sends them through roto.stroke: the render follows the last
stroke, and Undo / Redo step between the two results.
This commit is contained in:
tylerjenningsw
2026-10-27 14:13:40 -04:00
parent 0f8a65f6c2
commit b2cace1320
+27
View File
@@ -164,6 +164,33 @@ fn alpha_at(s: &Session, f: u32) -> Vec<f32> {
img.data.iter().map(|p| p[3]).collect()
}
/// Green, then Alt (red) over part of the object, then green there again: the last stroke wins,
/// in the render and through Undo / Redo (#1646).
#[test]
fn roto_brush_strokes_correct_earlier_ones() {
let (mut s, clip, _) = painted(center, "disk-1646.mov");
let c = center(0);
let spot = [c[0], c[1] + 25.0];
let i = spot[1] as usize * W as usize + spot[0] as usize;
let paint = |s: &mut Session, kind: &str| {
s.execute_checked(
"roto.stroke",
json!({"layer": clip.0, "kind": kind, "points": line([spot[0] - 6.0, spot[1]], [spot[0] + 6.0, spot[1]]), "radius": 7}),
)
.unwrap();
};
assert!(alpha_at(&s, 0)[i] > 0.5, "the spot starts inside the matte");
paint(&mut s, "bg");
assert!(alpha_at(&s, 0)[i] < 0.5, "Alt removes it");
paint(&mut s, "fg");
assert!(alpha_at(&s, 0)[i] > 0.5, "green over the Alt stroke restores it");
assert!(iou_at(&mut s, clip, 0, c) > 0.95);
assert!(s.undo());
assert!(alpha_at(&s, 0)[i] < 0.5, "undo brings the removal back");
assert!(s.redo());
assert!(alpha_at(&s, 0)[i] > 0.5, "redo restores it again");
}
#[test]
fn roto_brush_segments_and_propagates() {
let (mut s, clip, uid) = painted(center, "disk-a.mov");