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 ToString)[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 ToString,
    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: Arc<Galley>, color: Color32)[src]

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

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

Trait Implementations

impl Clone for Painter[src]

fn clone(&self) -> Painter[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

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]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

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

Performs the conversion.

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.

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

Performs the conversion.