pub struct OverlayShapeItem {Show 15 fields
pub position: [f32; 2],
pub size: [f32; 2],
pub shape: OverlayShape,
pub fill: OverlayFill,
pub opacity: f32,
pub border_colour: [f32; 4],
pub border_width: f32,
pub border_mode: BorderMode,
pub z_order: i32,
pub texture: Option<OverlayTextureId>,
pub shadow_colour: [f32; 4],
pub shadow_radius: f32,
pub shadow_offset: [f32; 2],
pub animation: OverlayAnimation,
pub backdrop_blur: f32,
}Expand description
A screen-space overlay shape rendered with a signed-distance function.
Each item becomes a single bounding quad on the GPU. The fragment shader evaluates an SDF to produce anti-aliased fill, border, and discard regions.
fill controls the interior colour. Use OverlayFill::Solid for a flat
colour or OverlayFill::LinearGradient for a two-colour gradient.
When texture is set the shape samples the uploaded image as its fill.
In that case fill must be OverlayFill::Solid; the solid colour acts as
a tint multiplied with each texel. Use [1.0, 1.0, 1.0, 1.0] for no tint.
The SDF boundary, border, and AA apply the same way regardless of fill mode.
§Examples
// Rounded-rect panel background.
let panel = OverlayShapeItem {
position: [20.0, 20.0],
size: [300.0, 200.0],
shape: OverlayShape::Rect { corner_radius: 8.0 },
fill: OverlayFill::Solid([0.1, 0.1, 0.1, 0.85]),
border_width: 1.0,
border_colour: [0.4, 0.4, 0.4, 1.0],
..Default::default()
};
// Circle with a left-to-right gradient.
let grad_dot = OverlayShapeItem {
position: [100.0, 100.0],
size: [60.0, 60.0],
shape: OverlayShape::Circle,
fill: OverlayFill::LinearGradient {
start_colour: [0.0, 0.4, 1.0, 1.0],
end_colour: [0.0, 1.0, 0.5, 1.0],
angle: 0.0,
},
..Default::default()
};Fields§
§position: [f32; 2]Top-left position in logical pixels from the viewport top-left.
size: [f32; 2]Width and height in logical pixels.
shape: OverlayShapeWhich SDF shape to render.
fill: OverlayFillFill style: solid colour or linear gradient.
When texture is Some only OverlayFill::Solid is used; the colour
becomes a tint multiplied with each texture sample.
opacity: f32Overall opacity multiplier applied to both fill and border. Range 0.0-1.0.
border_colour: [f32; 4]RGBA border colour in linear float format.
border_width: f32Border thickness in logical pixels. 0.0 disables the border.
border_mode: BorderModeWhere the border sits relative to the shape edge. Default: Inset.
z_order: i32Draw order relative to other shapes. Lower values render first (further back).
texture: Option<OverlayTextureId>Optional texture fill. When set the shape samples the image uploaded
via ViewportGpuResources::upload_overlay_texture, clipped by the SDF
boundary. fill acts as a tint when this is Some.
shadow_colour: [f32; 4]RGBA colour of the outer shadow/glow halo. Default: transparent (no shadow).
shadow_radius: f32Blur spread of the shadow in logical pixels. 0.0 disables the shadow.
shadow_offset: [f32; 2]Offset of the shadow centre from the shape centre in logical pixels.
Positive X shifts right, positive Y shifts down. Default: [0.0, 0.0].
animation: OverlayAnimationOpacity animation. Resolved each frame during prepare() using
OverlayFrame::time. Default: OverlayAnimation::None.
backdrop_blur: f32Backdrop blur radius in logical pixels. When greater than zero the scene
content behind the shape is blurred (frosted glass effect) and the
fill colour is composited on top as a tint. 0.0 disables the
effect. Only active in render paths where the renderer owns the command
encoder (render, render_viewport); in paint/paint_to paths
blur shapes fall back to a regular solid fill.
Implementations§
Source§impl OverlayShapeItem
impl OverlayShapeItem
Sourcepub fn distance(&self, point: [f32; 2]) -> f32
pub fn distance(&self, point: [f32; 2]) -> f32
Signed distance from a screen-space point to the shape boundary.
The point is in logical pixels from the top-left of the viewport (the
same coordinate space as position). Negative values mean the point is
inside the shape; positive values mean it is outside.
This evaluates the same SDF used by the GPU shader, so the boundary matches what is rendered on screen (ignoring sub-pixel AA).
Trait Implementations§
Source§impl Clone for OverlayShapeItem
impl Clone for OverlayShapeItem
Source§fn clone(&self) -> OverlayShapeItem
fn clone(&self) -> OverlayShapeItem
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OverlayShapeItem
impl Debug for OverlayShapeItem
Auto Trait Implementations§
impl Freeze for OverlayShapeItem
impl RefUnwindSafe for OverlayShapeItem
impl Send for OverlayShapeItem
impl Sync for OverlayShapeItem
impl Unpin for OverlayShapeItem
impl UnsafeUnpin for OverlayShapeItem
impl UnwindSafe for OverlayShapeItem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.