Merge pull request #3418 from nanox333/fix/3368-cylinder-radius

Cylinder Wrap: Radius goes up to 30000 % (#3368)
This commit is contained in:
ash
2026-11-11 19:06:30 +05:30
committed by GitHub
+18 -1
View File
@@ -394,7 +394,7 @@ pub fn specs() -> Vec<EffectSpec> {
};
let render = || popup(&["Full", "Outside", "Inside"]);
let mut cyl = vec![
p("radius", "Radius", num(100.0), slider(0.0, 400.0, 0.0, 200.0, 1)),
p("radius", "Radius", num(100.0), slider(0.0, 30000.0, 0.0, 200.0, 1)),
p("position", "Position", pt(0.5, 0.5), ParamUi::Point),
p("rotation", "Rotation", num(0.0), ParamUi::Angle),
p("rotationX", "Rotation X", num(0.0), ParamUi::Angle),
@@ -565,6 +565,23 @@ mod tests {
assert_eq!(out.get(50 + 18, 10)[3], 0.0);
}
/// #3368: Radius takes the range After Effects' CC Cylinder has, up to 30000 %, and a cylinder
/// that large still renders (nearly flat, fully opaque) instead of clamping to 400 %.
#[test]
fn cylinder_radius_goes_up_to_thirty_thousand_percent() {
let spec = find("ec.perspective.cccylinder").unwrap();
let radius = spec.params.iter().find(|p| p.id == "radius").unwrap();
assert!(matches!(radius.ui, ParamUi::Slider { min, max, .. } if min == 0.0 && max == 30000.0), "{:?}", radius.ui);
// The cylinder's axis on the left edge: at 400 % its radius is 400 / 100 * 100 / 2π ≈ 63.7 px,
// so a pixel 70 px along is past it there and inside the 30000 % one.
let img = Image::filled(100, 20, [0.5, 0.5, 0.5, 1.0]);
let at_edge = |radius: f64| run("ec.perspective.cccylinder", &img, &[("radius", num(radius)), ("position", Value::Vec2([0.0, 10.0]))]).img;
let clamped = at_edge(400.0).get(70, 10);
assert_eq!(clamped[3], 0.0, "beyond a 400 % cylinder: {clamped:?}");
let px = at_edge(30000.0).get(70, 10);
assert!(px.iter().all(|v| v.is_finite()) && px[3] > 0.99, "{px:?}");
}
#[test]
fn cylinder_axis_rotations_affect_geometry_and_texture() {
let img = Image::filled(100, 100, [0.5, 0.5, 0.5, 1.0]);