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)
.
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]
pub fn new(
ctx: &mut Context,
width: u32,
height: u32,
samples: NumSamples
) -> GameResult<Canvas>
[src]
ctx: &mut Context,
width: u32,
height: u32,
samples: NumSamples
) -> GameResult<Canvas>
Create a new canvas with the given size and number of samples.
pub fn with_window_size(ctx: &mut Context) -> GameResult<Canvas>
[src]
Create a new canvas with the current window dimensions.
pub fn get_image(&self) -> &Image
[src]
Gets the backend Image
that is being rendered to.
pub fn into_inner(self) -> Image
[src]
Destroys the Canvas and returns the Image
it contains.
Trait Implementations
impl Drawable for Canvas
[src]
fn draw_ex(&self, ctx: &mut Context, param: DrawParam) -> GameResult<()>
[src]
Actually draws the object to the screen. Read more
fn set_blend_mode(&mut self, mode: Option<BlendMode>)
[src]
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
fn get_blend_mode(&self) -> Option<BlendMode>
[src]
Gets the blend mode to be used when drawing this drawable.
fn draw(&self, ctx: &mut Context, dest: Point2, rotation: f32) -> GameResult<()>
[src]
Draws the drawable onto the rendering target. Read more