pub struct PaintCtx<'a> {
pub environment: &'a Environment,
pub rect: Rect,
pub element: ElementId,
pub state: VisualState,
pub window: WindowId,
pub hovered_subtree: bool,
/* private fields */
}Fields§
§environment: &'a Environment§rect: Rect§element: ElementId§state: VisualState§window: WindowId§hovered_subtree: boolImplementations§
Source§impl PaintCtx<'_>
impl PaintCtx<'_>
pub fn shapes(&self) -> &ShapeCache
pub fn raster_options(&self) -> RasterOptions
pub fn translate(&mut self, dx: f32, dy: f32)
pub fn set_draw_offset(&mut self, offset: impl Into<Point>)
pub fn draw_offset(&self) -> Vec2
pub fn reset_draw_offset(&mut self)
pub fn save(&mut self)
pub fn restore(&mut self)
pub fn path_from_svg(&self, data: &str) -> Option<Path>
pub fn rect(&mut self, rect: Rect, color: Color)
pub fn rounded(&mut self, rect: Rect, radius: f32, color: Color)
pub fn circle(&mut self, center: Point, radius: f32, color: Color) -> Rect
pub fn fill_gradient_rect( &mut self, rect: Rect, stops: &[GradientStop], orientation: Orientation, ) -> Rect
pub fn knob(&mut self, center: Point, radius: f32, fill: Color) -> Rect
pub fn sv_field(&mut self, rect: Rect, hue01: f32) -> Rect
pub fn path(&mut self, path: &Path, width: f32, color: Color) -> Rect
pub fn text(&mut self, text: &str, size: f32, color: Color)
pub fn fill(&mut self, path: &Path, color: Color) -> Rect
pub fn fill_rule(&mut self, path: &Path, rule: FillRule, color: Color) -> Rect
pub fn stroke(&mut self, path: &Path, style: &StrokeStyle, color: Color) -> Rect
pub fn shape(&mut self, shape: &Shape, color: Color) -> Rect
pub fn draw_shape(&mut self, shape: &Shape, at: Point, color: Color) -> Rect
pub fn fill_gradient(&mut self, path: &Path, gradient: &Gradient) -> Rect
pub fn fill_gradient_rule( &mut self, path: &Path, rule: FillRule, gradient: &Gradient, ) -> Rect
pub fn rounded_rect_gradient( &mut self, rect: Rect, radius: f32, gradient: &Gradient, ) -> Rect
pub fn stroke_gradient( &mut self, path: &Path, style: &StrokeStyle, gradient: &Gradient, ) -> Rect
pub fn shadow( &mut self, rect: Rect, radius: f32, blur: f32, offset: Point, color: Color, ) -> Rect
pub fn inner_shadow( &mut self, rect: Rect, radius: f32, blur: f32, offset: Point, color: Color, ) -> Rect
pub fn shape_gradient_bands( &self, shape: &Shape, at: Point, gradient: &Gradient, band: f32, ) -> Vec<(Rect, Color, f32)>
pub fn push_gradient_bands(&mut self, bands: &[(Rect, Color, f32)]) -> Rect
pub fn draw_shape_gradient( &mut self, shape: &Shape, at: Point, gradient: &Gradient, band: f32, ) -> Rect
pub fn shape_gradient(&mut self, shape: &Shape, gradient: &Gradient) -> Rect
pub fn fill_rect(&mut self, rect: Rect, color: Color) -> Rect
pub fn bars(&mut self, bars: &[Rect], color: Color) -> Rect
pub fn waveform( &mut self, area: Rect, peaks: &[MinMax], opts: WaveformOpts, color: Color, ) -> Rect
pub fn waveform_window( &mut self, area: Rect, peaks: &Peaks, start_peak: usize, count: usize, opts: WaveformOpts, color: Color, ) -> (Rect, usize)
pub fn waveform_line( &mut self, area: Rect, peaks: &[MinMax], width: f32, color: Color, ) -> Rect
pub fn waveform_image( &mut self, area: Rect, peaks: &[MinMax], fg: Color, bg: Color, id: u64, version: u64, ) -> Rect
pub fn disk(&mut self, center: Point, radius: f32, color: Color) -> Rect
pub fn rounded_rect(&mut self, rect: Rect, radius: f32, color: Color) -> Rect
pub fn ellipse(&mut self, center: Point, rx: f32, ry: f32, color: Color) -> Rect
pub fn ellipse_outline( &mut self, center: Point, rx: f32, ry: f32, style: &StrokeStyle, color: Color, ) -> Rect
pub fn rect_outline( &mut self, rect: Rect, style: &StrokeStyle, color: Color, ) -> Rect
pub fn rounded_rect_outline( &mut self, rect: Rect, radius: f32, style: &StrokeStyle, color: Color, ) -> Rect
pub fn rounded_rect_corners( &mut self, rect: Rect, radii: impl Into<Radius>, color: Color, ) -> Rect
pub fn rounded_rect_corners_outline( &mut self, rect: Rect, radii: impl Into<Radius>, style: &StrokeStyle, color: Color, ) -> Rect
pub fn capsule( &mut self, from: Point, to: Point, radius: f32, color: Color, ) -> Rect
pub fn arrow( &mut self, from: Point, to: Point, width: f32, head_len: f32, head_width: f32, color: Color, ) -> Rect
pub fn arrow_styled( &mut self, from: Point, to: Point, style: &StrokeStyle, head_len: f32, head_width: f32, color: Color, ) -> Rect
pub fn cross( &mut self, center: Point, half: f32, width: f32, color: Color, ) -> Rect
pub fn x_marker( &mut self, center: Point, half: f32, width: f32, color: Color, ) -> Rect
pub fn regular_polygon( &mut self, center: Point, radius: f32, sides: u32, rotation_deg: f32, color: Color, ) -> Rect
pub fn regular_polygon_outline( &mut self, center: Point, radius: f32, sides: u32, rotation_deg: f32, style: &StrokeStyle, color: Color, ) -> Rect
pub fn star( &mut self, center: Point, outer_r: f32, inner_r: f32, points: u32, rotation_deg: f32, color: Color, ) -> Rect
pub fn star_outline( &mut self, center: Point, outer_r: f32, inner_r: f32, points: u32, rotation_deg: f32, style: &StrokeStyle, color: Color, ) -> Rect
pub fn ring( &mut self, center: Point, radius: f32, width: f32, color: Color, ) -> Rect
pub fn arc( &mut self, center: Point, radius: f32, from_deg: f32, to_deg: f32, width: f32, color: Color, ) -> Rect
pub fn sector( &mut self, center: Point, radius: f32, from_deg: f32, to_deg: f32, color: Color, ) -> Rect
pub fn donut_sector( &mut self, center: Point, inner_r: f32, outer_r: f32, from_deg: f32, to_deg: f32, color: Color, ) -> Rect
pub fn line(&mut self, from: Point, to: Point, width: f32, color: Color) -> Rect
pub fn line_crisp( &mut self, from: Point, to: Point, width: f32, color: Color, ) -> Rect
pub fn dotted_line( &mut self, from: Point, to: Point, width: f32, spacing: f32, color: Color, ) -> Rect
pub fn line_styled( &mut self, from: Point, to: Point, style: &StrokeStyle, color: Color, ) -> Rect
pub fn dashed_line( &mut self, from: Point, to: Point, width: f32, dash: impl Into<Dash>, color: Color, ) -> Rect
pub fn outline( &mut self, points: &[Point], style: &StrokeStyle, color: Color, ) -> Rect
pub fn polygon(&mut self, points: &[Point], color: Color) -> Rect
pub fn spline( &mut self, points: &[Point], tension: f32, style: &StrokeStyle, color: Color, ) -> Rect
pub fn curve( &mut self, from: Point, c1: Point, c2: Point, to: Point, style: &StrokeStyle, color: Color, ) -> Rect
pub fn curve_quad( &mut self, from: Point, control: Point, to: Point, style: &StrokeStyle, color: Color, ) -> Rect
pub fn draw_svg( &mut self, data: &str, style: Option<&StrokeStyle>, color: Color, ) -> Rect
pub fn draw_transformed( &mut self, path: &Path, transform: Transform, style: Option<&StrokeStyle>, color: Color, ) -> Rect
Source§impl PaintCtx<'_>
impl PaintCtx<'_>
pub fn theme(&self) -> Theme
pub fn runtime(&self) -> &Runtime
pub fn window_rect(&self) -> Rect
pub fn window_size(&self) -> Size
pub fn scale(&self) -> f32
pub fn safe_insets(&self) -> Edges
pub fn element(&self) -> ElementId
Sourcepub fn measure_text(&mut self, text: &str, size: f32) -> TextMetrics
pub fn measure_text(&mut self, text: &str, size: f32) -> TextMetrics
Measures a specific string.
Sourcepub fn text_metrics(&mut self, size: f32) -> TextMetrics
pub fn text_metrics(&mut self, size: f32) -> TextMetrics
Returns vertical metrics for the default font at size.
Use this instead of guessing a baseline offset: center a line box with
rect.top() + (rect.height() - metrics.height) * 0.5, then draw it at
that top edge with Self::draw_text_tl.
Sourcepub fn baseline_centered(rect_top: f32, rect_h: f32, size: f32) -> f32
pub fn baseline_centered(rect_top: f32, rect_h: f32, size: f32) -> f32
Baseline placed in the vertical center of a line box whose top is
rect_top and whose height is rect_h.
Prefer Self::text_metrics when the real font ascent is needed.
Sourcepub fn baseline_top(rect_top: f32, size: f32) -> f32
pub fn baseline_top(rect_top: f32, size: f32) -> f32
Approximate baseline for a line box whose top is rect_top.
Prefer Self::text_metrics when the real font ascent is needed.
pub fn quad(&mut self, rect: Rect, color: Color, radius: f32)
pub fn bordered_quad( &mut self, rect: Rect, background: Color, radius: f32, border_width: f32, border_color: Color, )
pub fn paint_box(&mut self, style: BoxStyle)
pub fn paint_box_in(&mut self, style: BoxStyle, rect: Rect)
pub fn push_clip(&mut self, rect: Rect)
pub fn pop_clip(&mut self)
pub fn push_rounded_clip(&mut self, rect: Rect, radius: f32)
pub fn list_clip_depth(&self) -> usize
pub fn push_backdrop(&mut self, rect: Rect, backdrop: Backdrop)
Sourcepub fn draw_text(
&mut self,
text: &str,
origin: (f32, f32),
size: f32,
color: Color,
)
pub fn draw_text( &mut self, text: &str, origin: (f32, f32), size: f32, color: Color, )
Draws a single line with origin at the text baseline.
The y coordinate is not a top edge: glyphs extend above it by the font
ascent. Use Self::draw_text_tl when positioning from the top-left of
a layout rectangle, or Self::text_metrics to center a line box.
Sourcepub fn draw_text_tl(
&mut self,
text: &str,
top_left: (f32, f32),
size: f32,
color: Color,
)
pub fn draw_text_tl( &mut self, text: &str, top_left: (f32, f32), size: f32, color: Color, )
Draws a single line with top_left at the top-left of its line box.
This is the counterpart of Self::draw_text, whose origin is the
baseline, and matches crate::Painter::text_tl.