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: Option<Viewport>
Viewport information.
view: Matrix2d
View transformation.
transform: Matrix2d
Current transformation.
draw_state: DrawState
Current draw state settings.
Methods
impl Context[src]
impl Contextpub fn new() -> Context[src]
pub fn new() -> ContextCreates a new drawing context.
pub fn new_viewport(viewport: Viewport) -> Context[src]
pub fn new_viewport(viewport: Viewport) -> ContextCreates 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]
pub fn new_abs(w: Scalar, h: Scalar) -> ContextCreates 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]
pub fn view(self) -> SelfMoves 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]
pub fn reset(self) -> SelfMoves 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]
pub fn store_view(self) -> SelfStores the current transform as new view.
pub fn get_view_size(&self) -> Vec2d[src]
pub fn get_view_size(&self) -> Vec2dComputes the current view size.
Trait Implementations
impl Transformed for Context[src]
impl Transformed for Contextfn append_transform(self, transform: Matrix2d) -> Self[src]
fn append_transform(self, transform: Matrix2d) -> SelfAppends transform to the current one.
fn prepend_transform(self, transform: Matrix2d) -> Self[src]
fn prepend_transform(self, transform: Matrix2d) -> SelfPrepends transform to the current one.
fn trans(self, x: Scalar, y: Scalar) -> Self[src]
fn trans(self, x: Scalar, y: Scalar) -> SelfTranslate x and y in local coordinates.
fn rot_rad(self, angle: Scalar) -> Self[src]
fn rot_rad(self, angle: Scalar) -> SelfRotate radians in local coordinates.
fn orient(self, x: Scalar, y: Scalar) -> Self[src]
fn orient(self, x: Scalar, y: Scalar) -> SelfOrients x axis to look at point locally. Read more
fn scale(self, sx: Scalar, sy: Scalar) -> Self[src]
fn scale(self, sx: Scalar, sy: Scalar) -> SelfScales in local coordinates.
fn shear(self, v: Vec2d) -> Self[src]
fn shear(self, v: Vec2d) -> SelfShears in local coordinates.
fn rot_deg(self, angle: Scalar) -> Self[src]
fn rot_deg(self, angle: Scalar) -> SelfRotates degrees in local coordinates.
fn zoom(self, s: Scalar) -> Self[src]
fn zoom(self, s: Scalar) -> SelfScales in both directions in local coordinates.
fn flip_v(self) -> Self[src]
fn flip_v(self) -> SelfFlips vertically in local coordinates.
fn flip_h(self) -> Self[src]
fn flip_h(self) -> SelfFlips horizontally in local coordinates.
fn flip_hv(self) -> Self[src]
fn flip_hv(self) -> SelfFlips horizontally and vertically in local coordinates.
impl Copy for Context[src]
impl Copy for Contextimpl Clone for Context[src]
impl Clone for Context