Repository navigation
fix(#3857): add configurable corner radius for caption background box #3869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -546,4 +546,18 @@ mod tests { | |
| t.enabled = false; | ||
| assert!(track_overlay(&t, Tick(5), 100, 100).is_none()); | ||
| } | ||
| #[test] | ||
| fn corner_radius_zero_and_nonzero_both_render_without_panic() { | ||
| let c = cap("Test"); | ||
| let st0 = CaptionStyle { background: true, box_corner_radius: 0.0, ..Default::default() }; | ||
| assert!(render_caption(&c, &st0, 1920, 1080).is_some()); | ||
|
|
||
| let c2 = cap("Test"); | ||
| let st20 = CaptionStyle { background: true, box_corner_radius: 20.0, ..Default::default() }; | ||
| assert!(render_caption(&c2, &st20, 1920, 1080).is_some()); | ||
|
|
||
| // Hostile large radius is clamped to half the box height, no panic. | ||
| let st_big = CaptionStyle { background: true, box_corner_radius: 99999.0, ..Default::default() }; | ||
|
Comment on lines
+552
to
+560
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add At revision
|
||
| assert!(render_caption(&cap("Clamp"), &st_big, 640, 360).is_some()); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: storytold/filmcraft
Length of output: 12965
Render the background as a rounded rectangle and test its corner coverage.
render_captionfillsbgwith rectangular coverage and never readsstyle.box_corner_radius. A nonzero radius therefore cannot produce rounded corners.Apply the clamped radius when generating the background mask. The test should assert that a nonzero-radius render leaves an interior corner pixel transparent while a center pixel remains filled.
is_some()only checks that rendering completed.The missing
CaptionStyle.box_corner_radiusfield is a separate compile-time correction.GitHub Actions: CI / gate _ gate (ubuntu-24.04)
[error] 552-560: The
cargo clippy --workspace --all-targets -- -D warningsstep failed: three E0560 errors becausefilmcraft_project::CaptionStylehas nobox_corner_radiusfield (lines 552, 556, and 560).