pub const SHAPE_WIPE: &str = "// An iris wipe through one of six shapes, opening from `center` or closing onto it.\n// The star\'s edges are linear in angle, so its sides bow a little; it reads as a star iris.\n\n// The shape\'s own distance: its boundary at 1 for size 1, growing outward.\nfn shape_metric(p: vec2f) -> f32 {\n let a = max(params.aspect, 0.1);\n if params.shape == 1u { return length(p / vec2f(a, 1.0)); }\n if params.shape == 2u { return abs(p.x) / a + abs(p.y); }\n if params.shape == 3u { return max(abs(p.x) / a, abs(p.y)); }\n if params.shape == 4u {\n // Five points, one up: the radius falls linearly in angle from 1 at a tip to 0.45\n // between two. The atan2 seam points down, between two tips, where this is continuous.\n let turn = atan2(p.x, -p.y) / 6.28318531 * 5.0;\n let tip = abs(fract(turn + 0.5) * 2.0 - 1.0);\n return length(p) / mix(1.0, 0.45, tip);\n }\n if params.shape == 5u {\n return min(max(abs(p.x) * 3.0, abs(p.y)), max(abs(p.x), abs(p.y) * 3.0));\n }\n return length(p);\n}\n\n// `uv` in the shape\'s frame: height units about the center, turned counter-clockwise on screen.\nfn shape_point(uv: vec2f) -> vec2f {\n let p = (uv - params.center) * vec2f(resolution().x / resolution().y, 1.0);\n let angle = params.rotation * 3.14159265 / 180.0;\n let c = cos(angle);\n let s = sin(angle);\n return vec2f(c * p.x - s * p.y, s * p.x + c * p.y);\n}\n\n// The size at which the shape covers the frame: the corner metric for convex shapes, analytic\n// bounds for the star (radius at least 0.45) and the cross.\nfn shape_reach() -> f32 {\n let c0 = shape_point(vec2f(0.0, 0.0));\n let c1 = shape_point(vec2f(1.0, 0.0));\n let c2 = shape_point(vec2f(0.0, 1.0));\n let c3 = shape_point(vec2f(1.0, 1.0));\n if params.shape == 4u {\n return max(max(length(c0), length(c1)), max(length(c2), length(c3))) / 0.45;\n }\n if params.shape == 5u {\n let a = abs(vec4f(c0.x, c1.x, c2.x, c3.x));\n let b = abs(vec4f(c0.y, c1.y, c2.y, c3.y));\n let across = max(a * 3.0, b);\n let along = max(a, b * 3.0);\n return min(\n max(max(across.x, across.y), max(across.z, across.w)),\n max(max(along.x, along.y), max(along.z, along.w)),\n );\n }\n return max(max(shape_metric(c0), shape_metric(c1)), max(shape_metric(c2), shape_metric(c3)));\n}\n\nfn transition(uv: vec2f) -> vec4f {\n let m = shape_metric(shape_point(uv));\n let footprint = fwidthFine(m);\n let closing = params.closing != 0u;\n let amount = select(progress(), 1.0 - progress(), closing);\n let edge = amount * (shape_reach() + params.softness);\n let outside = builtin_aa_ramp(edge - params.softness, edge, m, footprint);\n return mix(from_color(uv), to_color(uv), select(1.0 - outside, outside, closing));\n}\n";Expand description
Iris wipe through one of several shapes transition body.