Struct egui::Painter[][src]

pub struct Painter { /* fields omitted */ }

Helper to paint shapes and text to a specific region on a specific layer.

All coordinates are screen coordinates in the unit points (one point can consist of many physical pixels).

Implementations

impl Painter[src]

pub fn new(ctx: CtxRef, layer_id: LayerId, clip_rect: Rect) -> Self[src]

#[must_use]pub fn with_layer_id(self, layer_id: LayerId) -> Self[src]

pub fn set_layer_id(&mut self, layer_id: LayerId)[src]

redirect

pub fn sub_region(&self, rect: Rect) -> Self[src]

Create a painter for a sub-region of this Painter.

The clip-rect of the returned Painter will be the intersection of the given rectangle and the clip_rect() of this Painter.

impl Painter[src]

pub fn layer_id(&self) -> LayerId[src]

Where we paint

pub fn clip_rect(&self) -> Rect[src]

Everything painted in this Painter will be clipped against this. This means nothing outside of this rectangle will be visible on screen.

pub fn set_clip_rect(&mut self, clip_rect: Rect)[src]

Everything painted in this Painter will be clipped against this. This means nothing outside of this rectangle will be visible on screen.

pub fn round_to_pixel(&self, point: f32) -> f32[src]

Useful for pixel-perfect rendering

pub fn round_vec_to_pixels(&self, vec: Vec2) -> Vec2[src]

Useful for pixel-perfect rendering

pub fn round_pos_to_pixels(&self, pos: Pos2) -> Pos2[src]

Useful for pixel-perfect rendering

impl Painter[src]

pub fn add(&self, shape: Shape) -> ShapeIdx[src]

It is up to the caller to make sure there is room for this. Can be used for free painting. NOTE: all coordinates are screen coordinates!

pub fn extend(&self, shapes: Vec<Shape>)[src]

Add many shapes at once.

Calling this once is generally faster than calling Self::add multiple times.

pub fn set(&self, idx: ShapeIdx, shape: Shape)[src]

Modify an existing Shape.

impl Painter[src]

pub fn debug_rect(
    &mut self,
    rect: Rect,
    color: Color32,
    text: impl Into<String>
)
[src]

pub fn error(&self, pos: Pos2, text: impl Display) -> Rect[src]

impl Painter[src]

pub fn line_segment(&self, points: [Pos2; 2], stroke: impl Into<Stroke>)[src]

pub fn circle(
    &self,
    center: Pos2,
    radius: f32,
    fill_color: impl Into<Color32>,
    stroke: impl Into<Stroke>
)
[src]

pub fn circle_filled(
    &self,
    center: Pos2,
    radius: f32,
    fill_color: impl Into<Color32>
)
[src]

pub fn circle_stroke(
    &self,
    center: Pos2,
    radius: f32,
    stroke: impl Into<Stroke>
)
[src]

pub fn rect(
    &self,
    rect: Rect,
    corner_radius: f32,
    fill_color: impl Into<Color32>,
    stroke: impl Into<Stroke>
)
[src]

pub fn rect_filled(
    &self,
    rect: Rect,
    corner_radius: f32,
    fill_color: impl Into<Color32>
)
[src]

pub fn rect_stroke(
    &self,
    rect: Rect,
    corner_radius: f32,
    stroke: impl Into<Stroke>
)
[src]

pub fn arrow(&self, origin: Pos2, vec: Vec2, stroke: Stroke)[src]

Show an arrow starting at origin and going in the direction of vec, with the length vec.length().

impl Painter[src]

pub fn text(
    &self,
    pos: Pos2,
    anchor: Align2,
    text: impl Into<String>,
    text_style: TextStyle,
    text_color: Color32
) -> Rect
[src]

Lay out and paint some text.

To center the text at the given position, use anchor: (Center, Center).

Returns where the text ended up.

pub fn galley(
    &self,
    pos: Pos2,
    galley: Galley,
    text_style: TextStyle,
    color: Color32
)
[src]

Paint text that has already been layed out in a Galley.

pub fn galley_with_italics(
    &self,
    pos: Pos2,
    galley: Galley,
    text_style: TextStyle,
    color: Color32,
    fake_italics: bool
)
[src]

Trait Implementations

impl Clone for Painter[src]

Auto Trait Implementations

impl !RefUnwindSafe for Painter

impl Send for Painter

impl Sync for Painter

impl Unpin for Painter

impl !UnwindSafe for Painter

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.