Skip to main content

STAR_WIPE

Constant STAR_WIPE 

Source
pub const STAR_WIPE: &str = "// Port of gl-transitions/transitions/StarWipe.glsl\n// Author: Ben Lucas\n// License: MIT\n// alpha2: the inside test is a signed value, antialiased; border_color is premultiplied.\nfn star_rotate(v: vec2f, theta: f32) -> vec2f {\n    let cos_theta = cos(theta);\n    let sin_theta = sin(theta);\n    return vec2f(cos_theta * v.x - sin_theta * v.y, sin_theta * v.x + cos_theta * v.y);\n}\n\n// Upstream\'s inStar(uv, center, radius) is radius + star_value(uv, center) > 0. Neighbouring\n// sectors mirror each other, so the value is continuous across their seams.\nfn star_value(uv: vec2f, center: vec2f) -> f32 {\n    let star_angle = 1.2566370614359172;\n    let centered = star_rotate(uv - center, params.star_rotation * star_angle);\n    let theta = atan2(centered.y, centered.x) + 3.141592653589793;\n    let rotated = star_rotate(centered, -star_angle * (floor(theta / star_angle) + 0.5));\n    return rotated.x * 0.3 - abs(rotated.y);\n}\n\nfn gl_transition(uv: vec2f) -> vec4f {\n    let thickness = params.border_thickness;\n    let scaled = (2.0 * thickness + 1.0) * progress() - thickness;\n    let value = star_value(uv, params.star_center);\n    let inner = builtin_aa_step(-scaled, value);\n    let outer = builtin_aa_step(-(scaled + thickness), value);\n    let bordered = mix(gl_from_color(uv), builtin_premultiply(params.border_color), outer);\n    return mix(bordered, gl_to_color(uv), inner);\n}\n";
Expand description

Bordered star wipe transition body.