Skip to main content

SLIDES

Constant SLIDES 

Source
pub const SLIDES: &str = "// Port of gl-transitions/transitions/Slides.glsl\n// Author: Mark Craig\n// License: MIT\n// alpha2: `type` is the `origin` enum and `In` is `slide_in`; the slide\'s edges are\n// antialiased.\n\n// The top-left corner of the sliding picture, in y-down coordinates.\nfn slides_corner(rad: f32) -> vec2f {\n    let half = rad / 2.0;\n    switch params.origin {\n        case 0u: { return vec2f(0.5 - half, 0.0); }\n        case 1u: { return vec2f(1.0 - rad, 0.5 - half); }\n        case 2u: { return vec2f(0.5 - half, 1.0 - rad); }\n        case 3u: { return vec2f(0.0, 0.5 - half); }\n        case 4u: { return vec2f(1.0 - rad, 0.0); }\n        case 5u: { return vec2f(1.0 - rad, 1.0 - rad); }\n        case 6u: { return vec2f(0.0, 1.0 - rad); }\n        case 7u: { return vec2f(0.0, 0.0); }\n        default: { return vec2f(0.5 - half, 0.5 - half); }\n    }\n}\n\nfn gl_transition(uv: vec2f) -> vec4f {\n    let slide_in = params.slide_in != 0u;\n    let rad = select(1.0 - progress(), progress(), slide_in);\n    let corner = slides_corner(rad);\n    let down = vec2f(uv.x, 1.0 - uv.y);\n    let local = (down - corner) / rad;\n    let width = 1.0 / (resolution() * rad);\n    let inside = builtin_interval_coverage(local.x, width.x) * builtin_interval_coverage(local.y, width.y);\n    let uv2 = vec2f(local.x, 1.0 - local.y);\n    let moving = select(gl_from_color(uv2), gl_to_color(uv2), slide_in);\n    let still = select(gl_to_color(uv), gl_from_color(uv), slide_in);\n    return mix(still, moving, inside);\n}\n";
Expand description

Scaling slide from an edge, a corner or the centre transition body.