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

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

Drawing 2d context.

Fields

viewport

Viewport information.

view

View transformation.

transform

Current transformation.

draw_state

Current draw state settings.

Methods

impl Context

fn new() -> Context

Creates a new drawing context.

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.

fn new_abs(w: Scalar, h: Scalar) -> 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.

fn view(self) -> Self

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.

fn reset(self) -> Self

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.

fn store_view(self) -> Self

Stores the current transform as new view.

fn get_view_size(&self) -> Vec2d

Computes the current view size.

Trait Implementations

impl Transformed for Context

fn append_transform(self, transform: Matrix2d) -> Self

fn prepend_transform(self, transform: Matrix2d) -> Self

fn trans(self, x: Scalar, y: Scalar) -> Self

fn rot_rad(self, angle: Scalar) -> Self

fn orient(self, x: Scalar, y: Scalar) -> Self

fn scale(self, sx: Scalar, sy: Scalar) -> Self

fn shear(self, v: Vec2d) -> Self

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

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

fn flip_v(self) -> Self

fn flip_h(self) -> Self

fn flip_hv(self) -> Self

Derived Implementations

impl Clone for Context

fn clone(&self) -> Context

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

impl Copy for Context