pub struct ShapeRenderer { /* private fields */ }Expand description
Per-frame shape geometry collector.
Implementations§
Source§impl ShapeRenderer
impl ShapeRenderer
Sourcepub fn new(
gpu: &GpuContext,
format: TextureFormat,
width: f32,
height: f32,
sample_count: u32,
) -> Self
pub fn new( gpu: &GpuContext, format: TextureFormat, width: f32, height: f32, sample_count: u32, ) -> Self
Create a new shape renderer with the given GPU context and surface format.
Sourcepub fn begin_frame(&mut self)
pub fn begin_frame(&mut self)
Clear geometry for a new frame.
Sourcepub fn set_viewport(&mut self, width: f32, height: f32)
pub fn set_viewport(&mut self, width: f32, height: f32)
Update the viewport size.
Sourcepub fn fill_rect(&mut self, rect: Rect, color: Color, corner_radius: f32)
pub fn fill_rect(&mut self, rect: Rect, color: Color, corner_radius: f32)
Add a filled rectangle.
Sourcepub fn stroke_rect(
&mut self,
rect: Rect,
color: Color,
width: f32,
corner_radius: f32,
)
pub fn stroke_rect( &mut self, rect: Rect, color: Color, width: f32, corner_radius: f32, )
Add a stroked rectangle.
Sourcepub fn stroke_rounded_rect(
&mut self,
rect: Rect,
color: Color,
width: f32,
corner_radius: f32,
bg_color: Color,
)
pub fn stroke_rounded_rect( &mut self, rect: Rect, color: Color, width: f32, corner_radius: f32, bg_color: Color, )
Stroke a rounded rectangle with proper inner cutout.
When bg_color is not transparent, the inner region is filled with that
color, producing a proper stroked appearance on any background.
Sourcepub fn fill_circle(&mut self, center: Position, radius: f32, color: Color)
pub fn fill_circle(&mut self, center: Position, radius: f32, color: Color)
Add a filled circle.
Sourcepub fn stroke_circle(
&mut self,
center: Position,
radius: f32,
color: Color,
width: f32,
)
pub fn stroke_circle( &mut self, center: Position, radius: f32, color: Color, width: f32, )
Add a stroked circle.
Sourcepub fn fill_rect_gradient(
&mut self,
rect: Rect,
gradient: &Gradient,
corner_radius: f32,
)
pub fn fill_rect_gradient( &mut self, rect: Rect, gradient: &Gradient, corner_radius: f32, )
Fill a rectangle with a gradient (linear or radial).
Gradient colors are interpolated across the rectangle’s vertices.
Sourcepub fn shadow_rect(&mut self, rect: Rect, shadow: &Shadow, corner_radius: f32)
pub fn shadow_rect(&mut self, rect: Rect, shadow: &Shadow, corner_radius: f32)
Draw a shadow behind a rectangle.
Sourcepub fn draw_image(&mut self, _handle: &ImageHandle, _rect: Rect)
pub fn draw_image(&mut self, _handle: &ImageHandle, _rect: Rect)
Draw an image (placeholder — textures require a separate pipeline).
Sourcepub fn line(&mut self, from: Position, to: Position, color: Color, width: f32)
pub fn line(&mut self, from: Position, to: Position, color: Color, width: f32)
Add a line segment.
Sourcepub fn flush(&mut self, gpu: &GpuContext, pass: &mut RenderPass<'_>)
pub fn flush(&mut self, gpu: &GpuContext, pass: &mut RenderPass<'_>)
Flush geometry and encode draw commands into the given render pass.
Sourcepub fn vertex_count(&self) -> usize
pub fn vertex_count(&self) -> usize
Current vertex count for statistics.
Sourcepub fn index_count(&self) -> usize
pub fn index_count(&self) -> usize
Current index/triangle count for statistics.
Sourcepub fn sample_count(&self) -> u32
pub fn sample_count(&self) -> u32
MSAA sample count configured for this renderer.
Auto Trait Implementations§
impl Freeze for ShapeRenderer
impl !RefUnwindSafe for ShapeRenderer
impl Send for ShapeRenderer
impl Sync for ShapeRenderer
impl Unpin for ShapeRenderer
impl UnsafeUnpin for ShapeRenderer
impl !UnwindSafe for ShapeRenderer
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
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>. Box<dyn Any> can
then be further downcast into Box<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>. Rc<Any> 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> 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 more