Struct macroquad_canvas::Canvas2D
source ·
[−]pub struct Canvas2D {
pub camera: Camera2D,
}Expand description
This struct represents the canvas, it’s basicaly a wrapper around Camera2D with convinience
methods to make life easier.
Note
Deref and DerefMut are implemented, which means you can access fields/methods from
Camera2D like so
let canvas = Canvas2D::new(800, 600);
println!("{}", canvas.zoom); // Prints camera zoomImplementation Detail
There’s a bug that mirrors render target on the Y axis (see https://github.com/not-fl3/macroquad/issues/171#issuecomment-880601087), as a workaround, the render target gets flipped vertically.
Fields
camera: Camera2DContains the camera which contains the render texture and other things.
Implementations
Calculate size and padding of the canvas so it can fit inside of the target and its position is in the center.
Example
let (left_padding, top_padding, dimensions) =
canvas.calculate_size_and_padding(screen_width(), screen_height());Calculate size of the canvas so it can fit inside of the target.
Draws canvas according to the screen.
It’s basically an alias to
canvas.draw(screen_width(), screen_height());Methods from Deref<Target = Camera2D>
Returns the screen space position for a 2d camera world space position Screen position in window space - from (0, 0) to (screen_width, screen_height())
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Canvas2D
impl UnwindSafe for Canvas2D
Blanket Implementations
Mutably borrows from an owned value. Read more
