[]Struct piston_window::context::Context

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.

Methods

impl Context

pub fn new() -> Context

Creates a new drawing context.

pub fn new_viewport(viewport: Viewport) -> Context

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

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

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

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

Stores the current transform as new view.

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

Computes the current view size.

Trait Implementations

impl Transformed for Context

fn rot_deg(self, angle: f64) -> Self

Rotates degrees in local coordinates.

fn trans_pos<P>(self, pos: P) -> Self where
    P: Into<[f64; 2]>, 

Translate position in local coordinates.

fn orient_pos<P>(self, pos: P) -> Self where
    P: Into<[f64; 2]>, 

Orients x axis to look at point locally.

fn scale_pos<P>(self, pos: P) -> Self where
    P: Into<[f64; 2]>, 

Scales in local coordinates.

fn zoom(self, s: f64) -> Self

Scales in both directions in local coordinates.

fn flip_v(self) -> Self

Flips vertically in local coordinates.

fn flip_h(self) -> Self

Flips horizontally in local coordinates.

fn flip_hv(self) -> Self

Flips horizontally and vertically in local coordinates.

fn shear_pos<P>(self, pos: P) -> Self where
    P: Into<[f64; 2]>, 

Shears in local coordinates.

impl Clone for Context

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

Performs copy-assignment from source. Read more

impl Copy for Context

Auto Trait Implementations

impl Send for Context

impl Sync for Context

Blanket Implementations

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

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

type Owned = T

The resulting type after obtaining ownership.

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

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.

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

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

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

impl<T> SetParameter for T

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

Sets value as a parameter of self.

impl<T> Erased for T