Struct DrawingArea

Source
pub struct DrawingArea<DB: DrawingBackend, CT: CoordTranslate> { /* private fields */ }
Expand description

The abstraction of a region

Implementations§

Source§

impl<DB: DrawingBackend, X: Ranged, Y: Ranged> DrawingArea<DB, RangedCoord<X, Y>>

Source

pub fn draw_mesh<DrawFunc>( &self, draw_func: DrawFunc, y_count_max: usize, x_count_max: usize, ) -> Result<(), DrawingAreaErrorKind<DB::ErrorType>>
where DrawFunc: FnMut(&mut DB, MeshLine<'_, X, Y>) -> Result<(), DrawingErrorKind<DB::ErrorType>>,

Draw the mesh on a area

Source

pub fn get_x_range(&self) -> Range<X::ValueType>

Get the range of X of the guest coordinate for current drawing area

Source

pub fn get_y_range(&self) -> Range<Y::ValueType>

Get the range of Y of the guest coordinate for current drawing area

Source§

impl<DB: DrawingBackend, CT: CoordTranslate> DrawingArea<DB, CT>

Source

pub fn get_base_pixel(&self) -> BackendCoord

Get the left upper conner of this area in the drawing backend

Source

pub fn strip_coord_spec(&self) -> DrawingArea<DB, Shift>

Strip the applied coordinate specification and returns a shift-based drawing area

Source

pub fn dim_in_pixel(&self) -> (u32, u32)

Get the area dimension in pixel

Source

pub fn get_pixel_range(&self) -> (Range<i32>, Range<i32>)

Get the pixel range of this area

Source

pub fn fill<ColorType: Color>( &self, color: &ColorType, ) -> Result<(), DrawingAreaErrorKind<DB::ErrorType>>

Fill the entire drawing area with a color

Source

pub fn draw_pixel<ColorType: Color>( &self, pos: CT::From, color: &ColorType, ) -> Result<(), DrawingAreaErrorKind<DB::ErrorType>>

Draw a single pixel

Source

pub fn present(&self) -> Result<(), DrawingAreaErrorKind<DB::ErrorType>>

Present all the pending changes to the backend

Source

pub fn draw<'a, E>( &self, element: &'a E, ) -> Result<(), DrawingAreaErrorKind<DB::ErrorType>>
where &'a E: PointCollection<'a, CT::From>, E: Drawable<DB>,

Draw an high-level element

Source

pub fn map_coordinate(&self, coord: &CT::From) -> BackendCoord

Map coordinate to the backend coordinate

Source§

impl<DB: DrawingBackend> DrawingArea<DB, Shift>

Source

pub fn shrink( self, left_upper: (u32, u32), dimension: (u32, u32), ) -> DrawingArea<DB, Shift>

Shrink the region, note all the locaitions are in guest coordinate

Source

pub fn apply_coord_spec<CT: CoordTranslate>( &self, coord_spec: CT, ) -> DrawingArea<DB, CT>

Apply a new coord transformation object and returns a new drawing area

Source

pub fn margin( &self, top: i32, bottom: i32, left: i32, right: i32, ) -> DrawingArea<DB, Shift>

Create a margin for the given drawing area and returns the new drawing area

Source

pub fn split_vertically(&self, y: i32) -> (Self, Self)

Split the drawing area vertically

Source

pub fn split_horizentally(&self, x: i32) -> (Self, Self)

Split the drawing area horizentally

Source

pub fn split_evenly(&self, (row, col): (usize, usize)) -> Vec<Self>

Split the drawing area evenly

Source

pub fn titled<'a, S: Into<TextStyle<'a>>>( &self, text: &str, style: S, ) -> Result<Self, DrawingAreaErrorKind<DB::ErrorType>>

Draw a title of the drawing area and return the remaining drawing area

Source

pub fn draw_text( &self, text: &str, style: &TextStyle<'_>, pos: BackendCoord, ) -> Result<(), DrawingAreaErrorKind<DB::ErrorType>>

Draw text on the drawing area

Source§

impl<DB: DrawingBackend, CT: CoordTranslate> DrawingArea<DB, CT>

Source

pub fn into_coord_spec(self) -> CT

Trait Implementations§

Source§

impl<DB: DrawingBackend, CT: CoordTranslate + Clone> Clone for DrawingArea<DB, CT>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<DB: DrawingBackend> From<DB> for DrawingArea<DB, Shift>

Source§

fn from(backend: DB) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<DB, CT> Freeze for DrawingArea<DB, CT>
where CT: Freeze,

§

impl<DB, CT> !RefUnwindSafe for DrawingArea<DB, CT>

§

impl<DB, CT> !Send for DrawingArea<DB, CT>

§

impl<DB, CT> !Sync for DrawingArea<DB, CT>

§

impl<DB, CT> Unpin for DrawingArea<DB, CT>
where CT: Unpin,

§

impl<DB, CT> !UnwindSafe for DrawingArea<DB, CT>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> SetParameter for T

Source§

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result
where T: Parameter<Self>,

Sets value as a parameter of self.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

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

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.