Type Definition ggez::graphics::Canvas[][src]

type Canvas = CanvasGeneric<GlBackendSpec>;

A canvas that can be rendered to instead of the screen (sometimes referred to as "render target" or "render to texture"). Set the canvas with the ggez::graphics::set_canvas() function, and then anything you draw will be drawn to the canvas instead of the screen. Resume drawing to the screen by calling ggez::graphics::set_canvas(None).

This is not an optimization tool. You may be tempted to say "I'll draw a scene to a Canvas and then just draw the single Canvas each frame." This is technically possible but makes life much harder than it needs to be (especially since the current implementation of Canvas has a number of hard-to-squash bugs.) If you want to draw things maximally efficiently, use SpriteBatch.

A Canvas allows creating render targets to be used instead of the screen. This allows graphics to be rendered to images off-screen in order to do things like saving to an image file or creating cool effects by using shaders that render to an image. If you just want to draw multiple things efficiently, look at SpriteBatch.

Methods

impl Canvas
[src]

Create a new canvas with the given size and number of samples.

Create a new canvas with the current window dimensions.

Gets the backend Image that is being rendered to.

Destroys the Canvas and returns the Image it contains.

Trait Implementations

impl Drawable for Canvas
[src]

Actually draws the object to the screen. Read more

Sets the blend mode to be used when drawing this drawable. This overrides the general graphics::set_blend_mode(). If None is set, defers to the blend mode set by graphics::set_blend_mode(). Read more

Gets the blend mode to be used when drawing this drawable.

Draws the drawable onto the rendering target. Read more