Skip to main content

RenderContext

Struct RenderContext 

Source
pub struct RenderContext {
    pub device: Arc<Device>,
    pub queue: Arc<Queue>,
    /* private fields */
}
Expand description

Rendering context passed to layers for drawing operations

Fields§

§device: Arc<Device>

GPU device

§queue: Arc<Queue>

GPU queue

Implementations§

Source§

impl RenderContext

Source

pub fn new( device: Arc<Device>, queue: Arc<Queue>, viewport: Viewport, theme: ChartTheme, style: ChartStyle, ) -> Self

Create a new render context

Source

pub fn set_stage_priority(&mut self, priority: i32)

Set the current stage priority for text grouping

Source

pub fn viewport(&self) -> &Viewport

Get the current viewport

Source

pub fn theme(&self) -> &ChartTheme

Get the current theme

Source

pub fn style(&self) -> &ChartStyle

Get the current style

Source

pub fn update( &mut self, viewport: Viewport, theme: ChartTheme, style: ChartStyle, )

Update viewport and theme

Source

pub fn add_vertices(&mut self, vertices: &[Vertex])

Add vertices to the current batch

Source

pub fn add_vertex(&mut self, vertex: Vertex)

Add a single vertex to the current batch

Source

pub fn draw_line( &mut self, start: [f32; 2], end: [f32; 2], color: Color, thickness: f32, )

Draw a line between two points

Source

pub fn draw_dashed_line( &mut self, start: [f32; 2], end: [f32; 2], color: Color, thickness: f32, dash: f32, gap: f32, )

Draw a dashed line between two points

Source

pub fn draw_rect(&mut self, rect: Rect, color: Color)

Draw a rectangle

Source

pub fn draw_triangle( &mut self, p1: [f32; 2], p2: [f32; 2], p3: [f32; 2], color: Color, )

Draw a filled triangle

Source

pub fn draw_circle(&mut self, center: [f32; 2], radius: f32, color: Color)

Draw a filled circle (approximated with triangles)

Source

pub fn draw_rounded_rect(&mut self, rect: Rect, radius: f32, color: Color)

Draw a filled rounded rectangle

Source

pub fn draw_rect_with_border( &mut self, rect: Rect, fill_color: Color, border_color: Color, border_width: f32, )

Draw a filled rectangle with border

Source

pub fn flush(&mut self) -> Result<()>

Flush the current vertex batch to GPU buffers

Source

pub fn commit(&mut self, render_pass: &mut RenderPass<'_>) -> Result<()>

Submit any uploaded vertex buffers to the active render pass.

Source

pub fn vertex_buffers(&self) -> &[VertexBuffer]

Get all vertex buffers for rendering

Source

pub fn clear(&mut self)

Clear all batched vertices and reset buffer allocation for new frame

Source

pub fn text_items(&self) -> Vec<TextItem>

Get all text items for rendering (flattened from all stages, in order)

Source

pub fn text_items_for_stage(&self, stage_priority: i32) -> &[TextItem]

Get text items for a specific stage priority

Source

pub fn text_stage_priorities(&self) -> Vec<i32>

Get all stage priorities that have text

Source

pub fn take_text_for_stage(&mut self, stage_priority: i32) -> Vec<TextItem>

Take text items for a specific stage (removes them from context)

Source

pub fn draw_text( &mut self, text: &str, x: f32, y: f32, color: Color, font_size: Option<f32>, )

Draw text at the specified position

Source

pub fn draw_text_anchored( &mut self, text: &str, x: f32, y: f32, color: Color, font_size: Option<f32>, anchor: TextAnchor, baseline: TextBaseline, )

Draw text with anchor and baseline options

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,