Function tcod::console::blit [] [src]

pub fn blit<T, U>(source_console: &T,
                  (source_x, source_y): (i32, i32),
                  (source_width, source_height): (i32, i32),
                  destination_console: &mut U,
                  (destination_x, destination_y): (i32, i32),
                  foreground_alpha: f32,
                  background_alpha: f32) where T: Console, U: Console

Blits the contents of one console onto an other

It takes a region from a given console (with an arbitrary location, width and height) and superimposes it on the destination console (at the given location). Note that when blitting, the source console's key color (set by set_key_color) will be ignored, making it possible to blit non-rectangular regions.

Arguments

Examples

Using blit with concrete types and Console trait objects:

use tcod::console as console;
use tcod::console::{Console, Root, Offscreen};

fn main() {
    let mut root = Root::initializer().init();

    let mut direct = Offscreen::new(20, 20);
    let mut boxed_direct = Box::new(Offscreen::new(20, 20));
    let mut trait_object: &Console = &Offscreen::new(20, 20);
    let mut boxed_trait: Box<Console> = Box::new(Offscreen::new(20, 20));

    console::blit(&direct, (0, 0), (20, 20), &mut root, (0, 0), 1.0, 1.0);
    console::blit(&boxed_direct, (0, 0), (20, 20), &mut root, (20, 0), 1.0, 1.0);
    console::blit(&trait_object, (0, 0), (20, 20), &mut root, (0, 20), 1.0, 1.0);
    console::blit(&boxed_trait, (0, 0), (20, 20), &mut root, (20, 20), 1.0, 1.0);
}