Struct piston_window::Context
source · [−]pub struct Context {
pub viewport: Option<Viewport>,
pub view: [[f64; 3]; 2],
pub transform: [[f64; 3]; 2],
pub draw_state: DrawState,
}
Expand description
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
sourceimpl Context
impl Context
sourcepub fn new_viewport(viewport: Viewport) -> 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.
sourcepub fn new_abs(w: f64, h: f64) -> Context
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.
sourcepub fn view(self) -> Context
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.
sourcepub fn reset(self) -> Context
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.
sourcepub fn store_view(self) -> Context
pub fn store_view(self) -> Context
Stores the current transform as new view.
sourcepub fn get_view_size(&self) -> [f64; 2]
pub fn get_view_size(&self) -> [f64; 2]
Computes the current view size.
Trait Implementations
sourceimpl Transformed for Context
impl Transformed for Context
sourcefn append_transform(self, transform: [[f64; 3]; 2]) -> Context
fn append_transform(self, transform: [[f64; 3]; 2]) -> Context
Appends transform to the current one.
sourcefn prepend_transform(self, transform: [[f64; 3]; 2]) -> Context
fn prepend_transform(self, transform: [[f64; 3]; 2]) -> Context
Prepends transform to the current one.
sourcefn trans_pos<P>(self, pos: P) -> Self where
P: Into<[f64; 2]>,
fn trans_pos<P>(self, pos: P) -> Self where
P: Into<[f64; 2]>,
Translate position in local coordinates.
impl Copy for Context
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more