From cc906c83cdf896d94b7ccf91258466714be631f6 Mon Sep 17 00:00:00 2001 From: Nick Senger Date: Wed, 8 Nov 2023 19:12:53 -0800 Subject: feat: quad shadows --- wgpu/src/layer.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'wgpu/src/layer.rs') diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs index 4ad12a88..7b54601b 100644 --- a/wgpu/src/layer.rs +++ b/wgpu/src/layer.rs @@ -198,6 +198,9 @@ impl<'a> Layer<'a> { border_radius, border_width, border_color, + shadow_color, + shadow_offset, + shadow_blur_radius, } => { let layer = &mut layers[current_layer]; @@ -210,6 +213,9 @@ impl<'a> Layer<'a> { border_color: color::pack(*border_color), border_radius: *border_radius, border_width: *border_width, + shadow_color: shadow_color.into_linear(), + shadow_offset: (*shadow_offset).into(), + shadow_blur_radius: *shadow_blur_radius, }; layer.quads.add(quad, background); -- cgit From b7b457a575cdd103915994f640c50262ce30a7c5 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 20 Jan 2024 12:11:18 +0100 Subject: Make `shadow` optional in `renderer::Quad` --- wgpu/src/layer.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'wgpu/src/layer.rs') diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs index 7b54601b..cb91878d 100644 --- a/wgpu/src/layer.rs +++ b/wgpu/src/layer.rs @@ -12,7 +12,9 @@ pub use text::Text; use crate::core; use crate::core::alignment; -use crate::core::{Color, Font, Pixels, Point, Rectangle, Size, Vector}; +use crate::core::{ + Color, Font, Pixels, Point, Rectangle, Shadow, Size, Vector, +}; use crate::graphics; use crate::graphics::color; use crate::graphics::Viewport; @@ -198,12 +200,16 @@ impl<'a> Layer<'a> { border_radius, border_width, border_color, - shadow_color, - shadow_offset, - shadow_blur_radius, + shadow, } => { let layer = &mut layers[current_layer]; + let shadow = shadow.unwrap_or_else(|| Shadow { + color: Color::TRANSPARENT, + offset: Vector::ZERO, + blur_radius: 0.0, + }); + let quad = Quad { position: [ bounds.x + translation.x, @@ -213,9 +219,9 @@ impl<'a> Layer<'a> { border_color: color::pack(*border_color), border_radius: *border_radius, border_width: *border_width, - shadow_color: shadow_color.into_linear(), - shadow_offset: (*shadow_offset).into(), - shadow_blur_radius: *shadow_blur_radius, + shadow_color: shadow.color.into_linear(), + shadow_offset: shadow.offset.into(), + shadow_blur_radius: shadow.blur_radius, }; layer.quads.add(quad, background); -- cgit From 25f182f933ea6b7c112c8f9a450a98dc9b9eebdd Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 20 Jan 2024 13:29:25 +0100 Subject: Introduce `Border` struct analogous to `Shadow` --- wgpu/src/layer.rs | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'wgpu/src/layer.rs') diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs index cb91878d..e213c95f 100644 --- a/wgpu/src/layer.rs +++ b/wgpu/src/layer.rs @@ -12,9 +12,7 @@ pub use text::Text; use crate::core; use crate::core::alignment; -use crate::core::{ - Color, Font, Pixels, Point, Rectangle, Shadow, Size, Vector, -}; +use crate::core::{Color, Font, Pixels, Point, Rectangle, Size, Vector}; use crate::graphics; use crate::graphics::color; use crate::graphics::Viewport; @@ -197,28 +195,20 @@ impl<'a> Layer<'a> { Primitive::Quad { bounds, background, - border_radius, - border_width, - border_color, + border, shadow, } => { let layer = &mut layers[current_layer]; - let shadow = shadow.unwrap_or_else(|| Shadow { - color: Color::TRANSPARENT, - offset: Vector::ZERO, - blur_radius: 0.0, - }); - let quad = Quad { position: [ bounds.x + translation.x, bounds.y + translation.y, ], size: [bounds.width, bounds.height], - border_color: color::pack(*border_color), - border_radius: *border_radius, - border_width: *border_width, + border_color: color::pack(border.color), + border_radius: border.radius.into(), + border_width: border.width, shadow_color: shadow.color.into_linear(), shadow_offset: shadow.offset.into(), shadow_blur_radius: shadow.blur_radius, -- cgit