Struct piston_window::context::Context[][src]

pub struct Context {
    pub viewport: Option<Viewport>,
    pub view: [[f64; 3]; 2],
    pub transform: [[f64; 3]; 2],
    pub draw_state: DrawState,
}

Drawing 2d context.

Fields

viewport: Option<Viewport>

Viewport information.

view: [[f64; 3]; 2]

View transformation.

transform: [[f64; 3]; 2]

Current transformation.

draw_state: DrawState

Current draw state settings.

Implementations

impl Context[src]

pub fn new() -> Context[src]

Creates a new drawing context.

pub fn new_viewport(viewport: Viewport) -> Context[src]

Creates a new context with absolute transform in point coordinates.

This function assumes the default coordinate system being centered with x axis pointing to the right and y axis pointing up.

Returns a drawing context with origin in the upper left corner and x axis pointing to the right and y axis pointing down.

pub fn new_abs(w: f64, h: f64) -> Context[src]

Creates a new drawing context in absolute coordinates.

This function assumes the default coordinate system being centered with x axis pointing to the right and y axis pointing up.

Returns a drawing context with origin in the upper left corner and x axis pointing to the right and y axis pointing down.

pub fn view(self) -> Context[src]

Moves the current transform to the view coordinate system.

This is usually [0.0, 0.0] in the upper left corner with the x axis pointing to the right and the y axis pointing down.

pub fn reset(self) -> Context[src]

Moves the current transform to the default coordinate system.

This is usually [0.0, 0.0] in the center with the x axis pointing to the right and the y axis pointing up.

pub fn store_view(self) -> Context[src]

Stores the current transform as new view.

pub fn get_view_size(&self) -> [f64; 2][src]

Computes the current view size.

Trait Implementations

impl Clone for Context[src]

impl Copy for Context[src]

impl Transformed for Context[src]

Auto Trait Implementations

impl RefUnwindSafe for Context

impl Send for Context

impl Sync for Context

impl Unpin for Context

impl UnwindSafe for Context

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> Pointable for T[src]

type Init = T

The type for initializers.

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.