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
impl RenderContext
Sourcepub fn new(
device: Arc<Device>,
queue: Arc<Queue>,
viewport: Viewport,
theme: ChartTheme,
style: ChartStyle,
) -> Self
pub fn new( device: Arc<Device>, queue: Arc<Queue>, viewport: Viewport, theme: ChartTheme, style: ChartStyle, ) -> Self
Create a new render context
Sourcepub fn set_stage_priority(&mut self, priority: i32)
pub fn set_stage_priority(&mut self, priority: i32)
Set the current stage priority for text grouping
Sourcepub fn theme(&self) -> &ChartTheme
pub fn theme(&self) -> &ChartTheme
Get the current theme
Sourcepub fn style(&self) -> &ChartStyle
pub fn style(&self) -> &ChartStyle
Get the current style
Sourcepub fn update(
&mut self,
viewport: Viewport,
theme: ChartTheme,
style: ChartStyle,
)
pub fn update( &mut self, viewport: Viewport, theme: ChartTheme, style: ChartStyle, )
Update viewport and theme
Sourcepub fn add_vertices(&mut self, vertices: &[Vertex])
pub fn add_vertices(&mut self, vertices: &[Vertex])
Add vertices to the current batch
Sourcepub fn add_vertex(&mut self, vertex: Vertex)
pub fn add_vertex(&mut self, vertex: Vertex)
Add a single vertex to the current batch
Sourcepub fn draw_line(
&mut self,
start: [f32; 2],
end: [f32; 2],
color: Color,
thickness: f32,
)
pub fn draw_line( &mut self, start: [f32; 2], end: [f32; 2], color: Color, thickness: f32, )
Draw a line between two points
Sourcepub fn draw_dashed_line(
&mut self,
start: [f32; 2],
end: [f32; 2],
color: Color,
thickness: f32,
dash: f32,
gap: f32,
)
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
Sourcepub fn draw_triangle(
&mut self,
p1: [f32; 2],
p2: [f32; 2],
p3: [f32; 2],
color: Color,
)
pub fn draw_triangle( &mut self, p1: [f32; 2], p2: [f32; 2], p3: [f32; 2], color: Color, )
Draw a filled triangle
Sourcepub fn draw_circle(&mut self, center: [f32; 2], radius: f32, color: Color)
pub fn draw_circle(&mut self, center: [f32; 2], radius: f32, color: Color)
Draw a filled circle (approximated with triangles)
Sourcepub fn draw_rounded_rect(&mut self, rect: Rect, radius: f32, color: Color)
pub fn draw_rounded_rect(&mut self, rect: Rect, radius: f32, color: Color)
Draw a filled rounded rectangle
Sourcepub fn draw_rect_with_border(
&mut self,
rect: Rect,
fill_color: Color,
border_color: Color,
border_width: f32,
)
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
Sourcepub fn commit(&mut self, render_pass: &mut RenderPass<'_>) -> Result<()>
pub fn commit(&mut self, render_pass: &mut RenderPass<'_>) -> Result<()>
Submit any uploaded vertex buffers to the active render pass.
Sourcepub fn vertex_buffers(&self) -> &[VertexBuffer]
pub fn vertex_buffers(&self) -> &[VertexBuffer]
Get all vertex buffers for rendering
Sourcepub fn text_items(&self) -> Vec<TextItem>
pub fn text_items(&self) -> Vec<TextItem>
Get all text items for rendering (flattened from all stages, in order)
Sourcepub fn text_items_for_stage(&self, stage_priority: i32) -> &[TextItem]
pub fn text_items_for_stage(&self, stage_priority: i32) -> &[TextItem]
Get text items for a specific stage priority
Sourcepub fn text_stage_priorities(&self) -> Vec<i32>
pub fn text_stage_priorities(&self) -> Vec<i32>
Get all stage priorities that have text
Sourcepub fn take_text_for_stage(&mut self, stage_priority: i32) -> Vec<TextItem>
pub fn take_text_for_stage(&mut self, stage_priority: i32) -> Vec<TextItem>
Take text items for a specific stage (removes them from context)
Sourcepub fn draw_text(
&mut self,
text: &str,
x: f32,
y: f32,
color: Color,
font_size: Option<f32>,
)
pub fn draw_text( &mut self, text: &str, x: f32, y: f32, color: Color, font_size: Option<f32>, )
Draw text at the specified position
Sourcepub fn draw_text_anchored(
&mut self,
text: &str,
x: f32,
y: f32,
color: Color,
font_size: Option<f32>,
anchor: TextAnchor,
baseline: TextBaseline,
)
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