Constant STYLE_WGSL
Source pub const STYLE_WGSL: &str = r#"
const FLAT_BEVEL: u32 = 16777216u;
fn flat_bevel_light(v: FlatVaryings, kind: u32, p: vec2f, inverse: mat2x2f) -> f32 {
let toward = v.material.yz;
if (kind == FLAT_RECT) {
let s = vec2f(flat_sign(p.x), flat_sign(p.y));
let q = abs(p) - max(v.shape.xy - vec2f(flat_corner(p, v.corners)), vec2f(0.0));
if (q.x > 0.0 && q.y > 0.0) {
return flat_coverage(vec3f(-dot(s * q, toward), -toward), inverse);
}
let x_lit = select(0.0, 1.0, s.x * toward.x > 0.0);
let y_lit = select(0.0, 1.0, s.y * toward.y > 0.0);
let x_side = flat_coverage(vec3f(q.y - q.x, -s.x, s.y), inverse);
return mix(y_lit, x_lit, x_side);
}
var side = 1.0;
if (kind == FLAT_RING || kind == FLAT_ARC) {
side = flat_sign(length(p) - v.shape.x);
}
return flat_coverage(vec3f(-side * dot(p, toward), -side * toward), inverse);
}
fn flat_bevel_over(v: FlatVaryings, kind: u32, p: vec2f, field: vec3f, inverse: mat2x2f, fill: vec4f, fill_cover: f32) -> vec4f {
if ((v.info.x & FLAT_BEVEL) == 0u) {
return fill;
}
let inner = flat_coverage(vec3f(field.x + v.material.x, field.yz), inverse);
let band = max(fill_cover - inner, 0.0);
let colour = mix(v.frame_y, v.frame_x, flat_bevel_light(v, kind, p, inverse));
let paint = vec4f(colour.rgb * colour.a, colour.a);
let share = select(0.0, band / fill_cover, fill_cover > 0.0);
return paint * band + fill * (1.0 - paint.a * share);
}
"#;