Skip to main content

ROTATE_SCALE_FADE

Constant ROTATE_SCALE_FADE 

Source
pub const ROTATE_SCALE_FADE: &str = "// Port of gl-transitions/transitions/rotate_scale_fade.glsl\n// Author: Fernando Kuteken\n// License: MIT\n// alpha2: turns in a square space, so the picture keeps its shape on any frame, and the frame\'s\n// edge against `back_color` is antialiased.\nfn gl_transition(uv: vec2f) -> vec4f {\n    let aspect = vec2f(ratio(), 1.0);\n    let difference = (uv - params.center) * aspect;\n    // Whole turns dropped first: the same angle, a small argument.\n    let angle = 6.28318531 * fract(params.rotations * progress());\n    let c = cos(angle);\n    let s = sin(angle);\n    let current_scale = mix(params.scale, 1.0, 2.0 * abs(progress() - 0.5));\n    let turned = vec2f(difference.x * c - difference.y * s, difference.x * s + difference.y * c);\n    let q = params.center + turned / current_scale / aspect;\n    let width = fwidthFine(q);\n    let inside = builtin_interval_coverage(q.x, width.x) * builtin_interval_coverage(q.y, width.y);\n    let image = mix(gl_from_color(q), gl_to_color(q), progress());\n    return mix(builtin_premultiply(params.back_color), image, inside);\n}\n";
Expand description

Spin and scale through the frame’s edge transition body.