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
source_console
: the type implementing the Console trait we want to take the blitted region fromsource_x
,source_y
: the coordinates of the blitted region's top left corner on the source consolesource_width
,source_height
: the width and height of the blitted region. With a value of 0, the width and height of the source console will be used.destination_console
: the type implementing the Console trait we want to blit todestination_x
,destination_y
: the coordinated of the blitted region's top left corner on the destination consoleforeground_alpha
,background_alpha
: the foreground and background opacity
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); }