Skip to main content

PaintCtx

Struct PaintCtx 

Source
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: bool

Implementations§

Source§

impl PaintCtx<'_>

Source

pub fn shapes(&self) -> &ShapeCache

Source

pub fn raster_options(&self) -> RasterOptions

Source

pub fn translate(&mut self, dx: f32, dy: f32)

Source

pub fn set_draw_offset(&mut self, offset: impl Into<Point>)

Source

pub fn draw_offset(&self) -> Vec2

Source

pub fn reset_draw_offset(&mut self)

Source

pub fn save(&mut self)

Source

pub fn restore(&mut self)

Source

pub fn path_from_svg(&self, data: &str) -> Option<Path>

Source

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

Source

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

Source

pub fn circle(&mut self, center: Point, radius: f32, color: Color) -> Rect

Source

pub fn fill_gradient_rect( &mut self, rect: Rect, stops: &[GradientStop], orientation: Orientation, ) -> Rect

Source

pub fn knob(&mut self, center: Point, radius: f32, fill: Color) -> Rect

Source

pub fn sv_field(&mut self, rect: Rect, hue01: f32) -> Rect

Source

pub fn path(&mut self, path: &Path, width: f32, color: Color) -> Rect

Source

pub fn text(&mut self, text: &str, size: f32, color: Color)

Source

pub fn fill(&mut self, path: &Path, color: Color) -> Rect

Source

pub fn fill_rule(&mut self, path: &Path, rule: FillRule, color: Color) -> Rect

Source

pub fn stroke(&mut self, path: &Path, style: &StrokeStyle, color: Color) -> Rect

Source

pub fn shape(&mut self, shape: &Shape, color: Color) -> Rect

Source

pub fn draw_shape(&mut self, shape: &Shape, at: Point, color: Color) -> Rect

Source

pub fn fill_gradient(&mut self, path: &Path, gradient: &Gradient) -> Rect

Source

pub fn fill_gradient_rule( &mut self, path: &Path, rule: FillRule, gradient: &Gradient, ) -> Rect

Source

pub fn rounded_rect_gradient( &mut self, rect: Rect, radius: f32, gradient: &Gradient, ) -> Rect

Source

pub fn stroke_gradient( &mut self, path: &Path, style: &StrokeStyle, gradient: &Gradient, ) -> Rect

Source

pub fn shadow( &mut self, rect: Rect, radius: f32, blur: f32, offset: Point, color: Color, ) -> Rect

Source

pub fn inner_shadow( &mut self, rect: Rect, radius: f32, blur: f32, offset: Point, color: Color, ) -> Rect

Source

pub fn shape_gradient_bands( &self, shape: &Shape, at: Point, gradient: &Gradient, band: f32, ) -> Vec<(Rect, Color, f32)>

Source

pub fn push_gradient_bands(&mut self, bands: &[(Rect, Color, f32)]) -> Rect

Source

pub fn draw_shape_gradient( &mut self, shape: &Shape, at: Point, gradient: &Gradient, band: f32, ) -> Rect

Source

pub fn shape_gradient(&mut self, shape: &Shape, gradient: &Gradient) -> Rect

Source

pub fn fill_rect(&mut self, rect: Rect, color: Color) -> Rect

Source

pub fn bars(&mut self, bars: &[Rect], color: Color) -> Rect

Source

pub fn waveform( &mut self, area: Rect, peaks: &[MinMax], opts: WaveformOpts, color: Color, ) -> Rect

Source

pub fn waveform_window( &mut self, area: Rect, peaks: &Peaks, start_peak: usize, count: usize, opts: WaveformOpts, color: Color, ) -> (Rect, usize)

Source

pub fn waveform_line( &mut self, area: Rect, peaks: &[MinMax], width: f32, color: Color, ) -> Rect

Source

pub fn waveform_image( &mut self, area: Rect, peaks: &[MinMax], fg: Color, bg: Color, id: u64, version: u64, ) -> Rect

Source

pub fn disk(&mut self, center: Point, radius: f32, color: Color) -> Rect

Source

pub fn rounded_rect(&mut self, rect: Rect, radius: f32, color: Color) -> Rect

Source

pub fn ellipse(&mut self, center: Point, rx: f32, ry: f32, color: Color) -> Rect

Source

pub fn ellipse_outline( &mut self, center: Point, rx: f32, ry: f32, style: &StrokeStyle, color: Color, ) -> Rect

Source

pub fn rect_outline( &mut self, rect: Rect, style: &StrokeStyle, color: Color, ) -> Rect

Source

pub fn rounded_rect_outline( &mut self, rect: Rect, radius: f32, style: &StrokeStyle, color: Color, ) -> Rect

Source

pub fn rounded_rect_corners( &mut self, rect: Rect, radii: impl Into<Radius>, color: Color, ) -> Rect

Source

pub fn rounded_rect_corners_outline( &mut self, rect: Rect, radii: impl Into<Radius>, style: &StrokeStyle, color: Color, ) -> Rect

Source

pub fn capsule( &mut self, from: Point, to: Point, radius: f32, color: Color, ) -> Rect

Source

pub fn arrow( &mut self, from: Point, to: Point, width: f32, head_len: f32, head_width: f32, color: Color, ) -> Rect

Source

pub fn arrow_styled( &mut self, from: Point, to: Point, style: &StrokeStyle, head_len: f32, head_width: f32, color: Color, ) -> Rect

Source

pub fn cross( &mut self, center: Point, half: f32, width: f32, color: Color, ) -> Rect

Source

pub fn x_marker( &mut self, center: Point, half: f32, width: f32, color: Color, ) -> Rect

Source

pub fn regular_polygon( &mut self, center: Point, radius: f32, sides: u32, rotation_deg: f32, color: Color, ) -> Rect

Source

pub fn regular_polygon_outline( &mut self, center: Point, radius: f32, sides: u32, rotation_deg: f32, style: &StrokeStyle, color: Color, ) -> Rect

Source

pub fn star( &mut self, center: Point, outer_r: f32, inner_r: f32, points: u32, rotation_deg: f32, color: Color, ) -> Rect

Source

pub fn star_outline( &mut self, center: Point, outer_r: f32, inner_r: f32, points: u32, rotation_deg: f32, style: &StrokeStyle, color: Color, ) -> Rect

Source

pub fn ring( &mut self, center: Point, radius: f32, width: f32, color: Color, ) -> Rect

Source

pub fn arc( &mut self, center: Point, radius: f32, from_deg: f32, to_deg: f32, width: f32, color: Color, ) -> Rect

Source

pub fn sector( &mut self, center: Point, radius: f32, from_deg: f32, to_deg: f32, color: Color, ) -> Rect

Source

pub fn donut_sector( &mut self, center: Point, inner_r: f32, outer_r: f32, from_deg: f32, to_deg: f32, color: Color, ) -> Rect

Source

pub fn line(&mut self, from: Point, to: Point, width: f32, color: Color) -> Rect

Source

pub fn line_crisp( &mut self, from: Point, to: Point, width: f32, color: Color, ) -> Rect

Source

pub fn dotted_line( &mut self, from: Point, to: Point, width: f32, spacing: f32, color: Color, ) -> Rect

Source

pub fn line_styled( &mut self, from: Point, to: Point, style: &StrokeStyle, color: Color, ) -> Rect

Source

pub fn dashed_line( &mut self, from: Point, to: Point, width: f32, dash: impl Into<Dash>, color: Color, ) -> Rect

Source

pub fn outline( &mut self, points: &[Point], style: &StrokeStyle, color: Color, ) -> Rect

Source

pub fn polygon(&mut self, points: &[Point], color: Color) -> Rect

Source

pub fn spline( &mut self, points: &[Point], tension: f32, style: &StrokeStyle, color: Color, ) -> Rect

Source

pub fn curve( &mut self, from: Point, c1: Point, c2: Point, to: Point, style: &StrokeStyle, color: Color, ) -> Rect

Source

pub fn curve_quad( &mut self, from: Point, control: Point, to: Point, style: &StrokeStyle, color: Color, ) -> Rect

Source

pub fn draw_svg( &mut self, data: &str, style: Option<&StrokeStyle>, color: Color, ) -> Rect

Source

pub fn draw_transformed( &mut self, path: &Path, transform: Transform, style: Option<&StrokeStyle>, color: Color, ) -> Rect

Source§

impl PaintCtx<'_>

Source

pub fn theme(&self) -> Theme

Source

pub fn runtime(&self) -> &Runtime

Source

pub fn window_rect(&self) -> Rect

Source

pub fn window_size(&self) -> Size

Source

pub fn scale(&self) -> f32

Source

pub fn safe_insets(&self) -> Edges

Source

pub fn element(&self) -> ElementId

Source

pub fn baseline_centered(rect_top: f32, rect_h: f32, size: f32) -> f32

Source

pub fn baseline_top(rect_top: f32, size: f32) -> f32

Source

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

Source

pub fn bordered_quad( &mut self, rect: Rect, background: Color, radius: f32, border_width: f32, border_color: Color, )

Source

pub fn paint_box(&mut self, style: BoxStyle)

Source

pub fn paint_box_in(&mut self, style: BoxStyle, rect: Rect)

Source

pub fn push_clip(&mut self, rect: Rect)

Source

pub fn pop_clip(&mut self)

Source

pub fn push_rounded_clip(&mut self, rect: Rect, radius: f32)

Source

pub fn list_clip_depth(&self) -> usize

Source

pub fn push_backdrop(&mut self, rect: Rect, backdrop: Backdrop)

Source

pub fn draw_text( &mut self, text: &str, origin: (f32, f32), size: f32, color: Color, )

Source

pub fn draw_text_weighted( &mut self, text: &str, origin: (f32, f32), size: f32, weight: FontWeight, color: Color, )

Source

pub fn draw_text_wrapped( &mut self, text: &str, origin: (f32, f32), size: f32, weight: FontWeight, width: f32, mode: WrapMode, color: Color, )

Source

pub fn draw_text_wrapped_spaced( &mut self, text: &str, origin: (f32, f32), size: f32, weight: FontWeight, width: f32, mode: WrapMode, spacing: LetterSpacing, color: Color, )

Source

pub fn draw_text_spaced( &mut self, text: &str, origin: (f32, f32), size: f32, spacing: LetterSpacing, color: Color, )

Source

pub fn draw_text_weighted_spaced( &mut self, text: &str, origin: (f32, f32), size: f32, weight: FontWeight, spacing: LetterSpacing, color: Color, )

Source

pub fn draw_text_styled_spaced( &mut self, text: &str, origin: (f32, f32), size: f32, weight: FontWeight, spacing: LetterSpacing, family: Option<&str>, style: FontStyle, color: Color, )

Source

pub fn draw_text_wrapped_styled_spaced( &mut self, text: &str, origin: (f32, f32), size: f32, weight: FontWeight, width: f32, mode: WrapMode, spacing: LetterSpacing, family: Option<&str>, style: FontStyle, color: Color, )

Source

pub fn draw_rich( &mut self, rich: &RichParagraph, origin: (f32, f32), default_color: Color, )

Source

pub fn draw_rich_spans( &mut self, spans: &[TextSpan], origin: (f32, f32), size: f32, width: f32, mode: WrapMode, spacing: LetterSpacing, align: RichAlign, default_color: Color, )

Source

pub fn text_width(&mut self, text: &str, size: f32) -> f32

Source

pub fn text_width_weighted( &mut self, text: &str, size: f32, weight: FontWeight, ) -> f32

Source

pub fn text_width_weighted_spaced( &mut self, text: &str, size: f32, weight: FontWeight, spacing: LetterSpacing, ) -> f32

Source

pub fn text_width_styled_spaced( &mut self, text: &str, size: f32, weight: FontWeight, spacing: LetterSpacing, family: Option<&str>, style: FontStyle, ) -> f32

Source

pub fn elide_spaced( &mut self, text: &str, size: f32, weight: FontWeight, max_width: f32, mode: ElideMode, spacing: LetterSpacing, ) -> String

Source

pub fn elide_styled_spaced( &mut self, text: &str, size: f32, weight: FontWeight, max_width: f32, mode: ElideMode, spacing: LetterSpacing, family: Option<&str>, style: FontStyle, ) -> String

Source

pub fn caret_positions( &mut self, text: &str, size: f32, weight: FontWeight, ) -> Vec<f32>

Source

pub fn caret_positions_spaced( &mut self, text: &str, size: f32, weight: FontWeight, spacing: LetterSpacing, ) -> Vec<f32>

Source

pub fn shape_rich_full( &mut self, spans: &[TextSpan], size: f32, width: f32, mode: WrapMode, spacing: LetterSpacing, align: RichAlign, ) -> Rc<RichParagraph>

Source

pub fn scale_factor(&self) -> f32

Source

pub fn request_frame(&self)

Source

pub fn live_color_exp(&self, prop: Prop, target: Color, rate: f32) -> Color

Source

pub fn draw_sprite( &mut self, key: u64, width: u32, height: u32, alpha: &[u8], rect: Rect, color: Color, )

Source

pub fn image(&mut self, rect: Rect, uv: [f32; 4], source: ImageSource)

Source

pub fn show_overlay(&self, entry: OverlayEntry) -> OverlayId

Source

pub fn hide_overlay(&self, id: OverlayId) -> bool

Source

pub fn has_overlay(&self, id: OverlayId) -> bool

Source

pub fn overlay_rect(&self, id: OverlayId) -> Option<Rect>

Source

pub fn drag_session(&self) -> Option<DragSession>

Source

pub fn is_drag_target(&self) -> bool

Source

pub fn has_focus_within(&self) -> bool

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for PaintCtx<'a>

§

impl<'a> !Send for PaintCtx<'a>

§

impl<'a> !Sync for PaintCtx<'a>

§

impl<'a> !UnwindSafe for PaintCtx<'a>

§

impl<'a> Freeze for PaintCtx<'a>

§

impl<'a> Unpin for PaintCtx<'a>

§

impl<'a> UnsafeUnpin for PaintCtx<'a>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.