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
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][+]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> From<T> for T
[src][+]
impl<T, U> Into<U> for T where
U: From<T>,
[src][+]
U: From<T>,
impl<T> Pointable for T
[src][+]
impl<T> ToOwned for T where
T: Clone,
[src][+]
T: Clone,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,