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

Creates a new drawing 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.

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.

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.

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.

Stores the current transform as new view.

Computes the current view size.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Appends transform to the current one.

Prepends transform to the current one.

Translate x and y in local coordinates.

Rotate radians in local coordinates.

Orients x axis to look at point locally. Read more

Scales in local coordinates.

Shears in local coordinates.

Rotates degrees in local coordinates.

Translate position in local coordinates.

Orients x axis to look at point locally.

Scales in local coordinates.

Scales in both directions in local coordinates.

Flips vertically in local coordinates.

Flips horizontally in local coordinates.

Flips horizontally and vertically in local coordinates.

Shears in local coordinates.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.