box-shadow clipping fix (#16790)
# Objective
Instead of clipping the non-visable sections of box-shadows, the shadow
is scaled to fit into the remaining area after clipping because the
normalized coordinates that are meant to border the unclipped subsection
of the shadow are always set to `[Vec2::ZERO, Vec2::X, Vec2::ONE,
Vec2::Y]`,
## Solution
Calculate the coordinates for the corners of the visible area.
## Testing
Test app:
```rust
use bevy::color::palettes::css::RED;
use bevy::color::palettes::css::WHITE;
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.run();
}
fn setup(mut commands: Commands) {
commands.spawn(Camera2d);
commands
.spawn(Node {
..Default::default()
})
.with_children(|commands| {
commands
.spawn((
Node {
width: Val::Px(100.),
height: Val::Px(100.),
margin: UiRect {
left: Val::Px(100.),
top: Val::Px(300.),
..Default::default()
},
overflow: Overflow::clip(),
..Default::default()
},
BackgroundColor(WHITE.into()),
))
.with_children(|commands| {
commands.spawn((
Node {
position_type: PositionType::Absolute,
left: Val::Px(50.),
top: Val::Px(50.),
width: Val::Px(100.),
height: Val::Px(100.),
..Default::default()
},
BackgroundColor(RED.into()),
BoxShadow::from(ShadowStyle {
x_offset: Val::ZERO,
y_offset: Val::ZERO,
spread_radius: Val::Px(50.),
blur_radius: Val::Px(6.),
..Default::default()
}),
));
});
});
}
```
Main:
<img width="103" alt="bad_shadow"
src="https://github.com/user-attachments/assets/6f7ade0e-959f-4d18-92e8-903630eb8cd3"
/>
This PR:
<img width="98" alt="clipped_shadow"
src="https://github.com/user-attachments/assets/7f576c94-908c-4fe6-abaa-f18fefe05207"
/>