shell/elements: Fix corners order for clipping/shadows
This commit is contained in:
parent
ea470f0a4b
commit
b6f0855a31
5 changed files with 34 additions and 28 deletions
|
|
@ -97,10 +97,10 @@ where
|
|||
Uniform::new(
|
||||
"corner_radius",
|
||||
[
|
||||
radius[0] as f32,
|
||||
radius[1] as f32,
|
||||
radius[2] as f32,
|
||||
radius[3] as f32,
|
||||
radius[1] as f32,
|
||||
radius[0] as f32,
|
||||
radius[2] as f32,
|
||||
],
|
||||
),
|
||||
Uniform::new(
|
||||
|
|
@ -142,10 +142,10 @@ where
|
|||
geo: Rectangle<f64, Logical>,
|
||||
radius: [u8; 4],
|
||||
) -> [Rectangle<f64, Logical>; 4] {
|
||||
let top_left = radius[0] as f64;
|
||||
let top_left = radius[3] as f64;
|
||||
let top_right = radius[1] as f64;
|
||||
let bottom_right = radius[2] as f64;
|
||||
let bottom_left = radius[3] as f64;
|
||||
let bottom_right = radius[0] as f64;
|
||||
let bottom_left = radius[2] as f64;
|
||||
|
||||
[
|
||||
Rectangle::new(geo.loc, Size::from((top_left, top_left))),
|
||||
|
|
|
|||
|
|
@ -30,17 +30,17 @@ float rounding_alpha(vec2 coords, vec2 size) {
|
|||
vec2 center;
|
||||
float radius;
|
||||
|
||||
if (coords.x < corner_radius.w && coords.y < corner_radius.w) {
|
||||
radius = corner_radius.w;
|
||||
if (coords.x < corner_radius.x && coords.y < corner_radius.x) {
|
||||
radius = corner_radius.x;
|
||||
center = vec2(radius, radius);
|
||||
} else if (size.x - corner_radius.y < coords.x && coords.y < corner_radius.y) {
|
||||
radius = corner_radius.y;
|
||||
center = vec2(size.x - radius, radius);
|
||||
} else if (size.x - corner_radius.x < coords.x && size.y - corner_radius.x < coords.y) {
|
||||
radius = corner_radius.x;
|
||||
center = vec2(size.x - radius, size.y - radius);
|
||||
} else if (coords.x < corner_radius.z && size.y - corner_radius.z < coords.y) {
|
||||
} else if (size.x - corner_radius.z < coords.x && size.y - corner_radius.z < coords.y) {
|
||||
radius = corner_radius.z;
|
||||
center = vec2(size.x - radius, size.y - radius);
|
||||
} else if (coords.x < corner_radius.w && size.y - corner_radius.w < coords.y) {
|
||||
radius = corner_radius.w;
|
||||
center = vec2(radius, size.y - radius);
|
||||
} else {
|
||||
return 1.0;
|
||||
|
|
|
|||
|
|
@ -74,17 +74,17 @@ float rounding_alpha(vec2 coords, vec2 size, vec4 corner_radius) {
|
|||
vec2 center;
|
||||
float radius;
|
||||
|
||||
if (coords.x < corner_radius.w && coords.y < corner_radius.w) {
|
||||
radius = corner_radius.w;
|
||||
if (coords.x < corner_radius.x && coords.y < corner_radius.x) {
|
||||
radius = corner_radius.x;
|
||||
center = vec2(radius, radius);
|
||||
} else if (size.x - corner_radius.y < coords.x && coords.y < corner_radius.y) {
|
||||
radius = corner_radius.y;
|
||||
center = vec2(size.x - radius, radius);
|
||||
} else if (size.x - corner_radius.x < coords.x && size.y - corner_radius.x < coords.y) {
|
||||
radius = corner_radius.x;
|
||||
center = vec2(size.x - radius, size.y - radius);
|
||||
} else if (coords.x < corner_radius.z && size.y - corner_radius.z < coords.y) {
|
||||
} else if (size.x - corner_radius.z < coords.x && size.y - corner_radius.z < coords.y) {
|
||||
radius = corner_radius.z;
|
||||
center = vec2(size.x - radius, size.y - radius);
|
||||
} else if (coords.x < corner_radius.w && size.y - corner_radius.w < coords.y) {
|
||||
radius = corner_radius.w;
|
||||
center = vec2(radius, size.y - radius);
|
||||
} else {
|
||||
return 1.0;
|
||||
|
|
|
|||
|
|
@ -82,6 +82,12 @@ impl ShadowShader {
|
|||
let offset = [0., 5.];
|
||||
let color = [0., 0., 0., 0.45];
|
||||
let radius = radius.map(|r| ceil(r as f64));
|
||||
let radius = [
|
||||
radius[3], // top_left
|
||||
radius[1], // top_right
|
||||
radius[0], // bottom_right
|
||||
radius[2], // bottom_left
|
||||
];
|
||||
|
||||
let width = softness;
|
||||
let sigma = width / 2.;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue