[][src]Struct graphics::context::Context

pub struct Context {
    pub viewport: Option<Viewport>,
    pub view: Matrix2d,
    pub transform: Matrix2d,
    pub draw_state: DrawState,
}

Drawing 2d context.

Fields

viewport: Option<Viewport>

Viewport information.

view: Matrix2d

View transformation.

transform: Matrix2d

Current transformation.

draw_state: DrawState

Current draw state settings.

Methods

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: Scalar, h: Scalar) -> 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) -> Self[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) -> Self[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) -> Self[src]

Stores the current transform as new view.

pub fn get_view_size(&self) -> Vec2d[src]

Computes the current view size.

Trait Implementations

impl Transformed for Context[src]

fn rot_deg(self, angle: Scalar) -> Self[src]

Rotates degrees in local coordinates.

fn trans_pos<P: Into<Vec2d>>(self, pos: P) -> Self[src]

Translate position in local coordinates.

fn orient_pos<P: Into<Vec2d>>(self, pos: P) -> Self[src]

Orients x axis to look at point locally.

fn scale_pos<P: Into<Vec2d>>(self, pos: P) -> Self[src]

Scales in local coordinates.

fn zoom(self, s: Scalar) -> Self[src]

Scales in both directions in local coordinates.

fn flip_v(self) -> Self[src]

Flips vertically in local coordinates.

fn flip_h(self) -> Self[src]

Flips horizontally in local coordinates.

fn flip_hv(self) -> Self[src]

Flips horizontally and vertically in local coordinates.

fn shear_pos<P: Into<Vec2d>>(self, pos: P) -> Self[src]

Shears in local coordinates.

impl Copy for Context[src]

impl Clone for Context[src]

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

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Sync for Context

impl Unpin for Context

impl Send for Context

impl UnwindSafe for Context

impl RefUnwindSafe for Context

Blanket Implementations

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

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

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for 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]