Skip to main content

BOX

Constant BOX 

Source
pub const BOX: &str = "// Port of gl-transitions/transitions/Box.glsl\n// Author: lql\n// License: MIT\n// alpha2: upstream\'s rectIn and location ints are a Bool and an Enum; the box\'s edges are\n// antialiased.\nfn gl_transition(uv: vec2f) -> vec4f {\n    let rect_in = params.rect_in != 0u;\n    let p = select(progress(), 1.0 - progress(), rect_in);\n    let centered = params.location == 0u;\n    let left = params.location == 1u || params.location == 2u;\n    let top = params.location == 1u || params.location == 3u;\n    let inset = 0.5 * (1.0 - p);\n    let x1 = select(select(1.0 - p, 0.0, left), inset, centered);\n    let y1 = select(select(0.0, 1.0 - p, top), inset, centered);\n    let x2 = select(select(1.0, p, left), 1.0 - inset, centered);\n    let y2 = select(select(p, 1.0, top), 1.0 - inset, centered);\n    let in_rect = builtin_aa_step(x1, uv.x) * builtin_aa_step(uv.x, x2)\n        * builtin_aa_step(y1, uv.y) * builtin_aa_step(uv.y, y2);\n    return mix(gl_from_color(uv), gl_to_color(uv), select(in_rect, 1.0 - in_rect, rect_in));\n}\n";
Expand description

Box opening from the center or a corner, or closing onto it, transition body.