pub struct Context {
pub viewport: Option<Viewport>,
pub view: Matrix2d,
pub transform: Matrix2d,
pub draw_state: DrawState,
}
Expand description
Drawing 2d context.
Fields§
§viewport: Option<Viewport>
Viewport information.
view: Matrix2d
View transformation.
transform: Matrix2d
Current transformation.
draw_state: DrawState
Current draw state settings.
Implementations§
source§impl 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: Scalar, h: Scalar) -> Context
pub 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.
sourcepub fn view(self) -> Self
pub 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.
sourcepub fn reset(self) -> Self
pub 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.
sourcepub fn store_view(self) -> Self
pub fn store_view(self) -> Self
Stores the current transform as new view.
sourcepub fn get_view_size(&self) -> Vec2d
pub fn get_view_size(&self) -> Vec2d
Computes the current view size.
Trait Implementations§
source§impl Transformed for Context
impl Transformed for Context
source§fn append_transform(self, transform: Matrix2d) -> Self
fn append_transform(self, transform: Matrix2d) -> Self
source§fn prepend_transform(self, transform: Matrix2d) -> Self
fn prepend_transform(self, transform: Matrix2d) -> Self
source§fn orient(self, x: Scalar, y: Scalar) -> Self
fn orient(self, x: Scalar, y: Scalar) -> Self
source§fn orient_pos<P: Into<Vec2d>>(self, pos: P) -> Self
fn orient_pos<P: Into<Vec2d>>(self, pos: P) -> Self
impl Copy for Context
Auto Trait Implementations§
impl Freeze for Context
impl RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnwindSafe for Context
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)