pub struct RootConsole(/* private fields */);
Expand description

Provides access to the root console of the Doryen engine.

Methods from Deref<Target = Console>§

source

pub fn resize(&mut self, width: u32, height: u32)

resizes the console

Examples found in repository?
examples/resize.rs (line 42)
41
42
43
fn resize_callback(root_console: &mut RootConsole, resized: Resized) {
    root_console.resize(resized.new_width / 8, resized.new_height / 8)
}
source

pub fn register_color(&mut self, name: &str, value: (u8, u8, u8, u8))

associate a name with a color for this console. The color name can then be used in Console::print_color Example

use doryen_rs::{Console, TextAlign};
let mut con=Console::new(80,25);
con.register_color("pink", (255, 0, 255, 255));
con.print_color(5, 5, "This text contains a #[pink]pink#[] word", TextAlign::Left, None);
Examples found in repository?
examples/lowfps.rs (line 32)
31
32
33
fn init(mut root_console: ResMut<RootConsole>) {
    root_console.register_color("red", (255, 92, 92, 255));
}
More examples
Hide additional examples
examples/demo/main.rs (line 102)
101
102
103
104
105
fn init(mut root_console: ResMut<RootConsole>) {
    root_console.register_color("white", WHITE);
    root_console.register_color("red", (255, 92, 92, 255));
    root_console.register_color("blue", (192, 192, 255, 255));
}
examples/basic.rs (line 76)
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
fn init(mut root_console: ResMut<RootConsole>, mut commands: Commands) {
    root_console.register_color("white", (255, 255, 255, 255));
    root_console.register_color("red", (255, 92, 92, 255));
    root_console.register_color("blue", (192, 192, 255, 255));

    let player = commands
        .spawn(PlayerBundle {
            player: Player,
            position: Position {
                x: (CONSOLE_WIDTH / 2) as i32,
                y: (CONSOLE_HEIGHT / 2) as i32,
            },
        })
        .id();

    let mouse = commands
        .spawn(MouseBundle {
            mouse: Mouse,
            position: Position { x: 0., y: 0. },
        })
        .id();

    commands.insert_resource(Entities { player, mouse });
}
source

pub fn get_width(&self) -> u32

Examples found in repository?
examples/demo/level.rs (line 206)
205
206
207
208
209
210
fn render_loading_level(mut root_console: ResMut<RootConsole>) {
    let x = (root_console.get_width() / 2) as i32;
    let y = (root_console.get_height() / 2) as i32;

    root_console.print_color(x, y, "#[white]Loading#[red]...", TextAlign::Center, None);
}
More examples
Hide additional examples
examples/lowfps.rs (line 38)
35
36
37
38
39
40
41
42
43
44
45
46
47
48
fn render(fps: Res<FpsInfo>, mut root_console: ResMut<RootConsole>) {
    let fps = fps.fps;

    let x = (root_console.get_width() / 2) as i32;
    let y = (root_console.get_height() / 2) as i32;

    root_console.print_color(
        x,
        y,
        &format!("Frames since last second : #[red]{}", fps),
        TextAlign::Center,
        None,
    );
}
examples/image.rs (line 58)
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
fn render(mut root_console: ResMut<RootConsole>, mut skull: NonSendMut<SkullImage>) {
    let root_console = &mut **root_console;
    let skull = &mut *skull;
    let scale = skull.scale_time.cos();
    root_console.clear(None, Some((0, 0, 0, 255)), None);
    skull.skull.blit_ex(
        root_console,
        (root_console.get_width() / 2) as f32,
        (root_console.get_height() / 2) as f32,
        scale,
        scale,
        skull.angle,
        None,
    );
}
examples/alpha.rs (line 77)
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
fn update_circle(
    root_console: Res<RootConsole>,
    entities: Res<Entities>,
    mut circle_query: Query<(&mut Position, &mut Radius, &mut Angle, &Circle)>,
) {
    let (mut position, mut radius, mut angle, _) = circle_query.get_mut(entities.circle).unwrap();

    // update the circle radius and center position
    angle.0 += 0.6;
    radius.0 = 10.0 + 3.0 * (angle.0 / 10.0).sin();
    let cs = (angle.0 / 20.0).cos();
    let sn = (angle.0 / 15.0).sin();
    position.x = (root_console.get_width() / 2) as f32 + cs * 15.0;
    position.y = (root_console.get_height() / 2) as f32 + sn * 15.0;
}
examples/blit.rs (line 118)
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
fn update_position_and_speed(
    root_console: Res<RootConsole>,
    step: Res<Step>,
    mut position_speed_query: Query<(&mut Position, &mut Speed)>,
) {
    if step.0 == 0 {
        for (mut position, mut speed) in position_speed_query.iter_mut() {
            let size = (
                root_console.get_width() as i32,
                root_console.get_height() as i32,
            );
            position.x += speed.x;
            if position.x == size.0 - 20 || position.x == 0 {
                speed.x = -speed.x;
            }
            position.y += speed.y;
            if position.y == size.1 - 20 || position.y == 0 {
                speed.y = -speed.y;
            }
        }
    }
}

fn update_alpha(mut console_query: Query<(&mut Alpha, &Console)>) {
    for (mut alpha, _) in console_query.iter_mut() {
        if alpha.value <= 0.0 || alpha.value >= 1.0 {
            alpha.step = -alpha.step;
        }
        alpha.value += alpha.step;
    }
}

fn update_step(mut step: ResMut<Step>) {
    step.0 = (step.0 + 1) % 10;
}

fn render(
    mut root_console: ResMut<RootConsole>,
    console_query: Query<(&Position, &Alpha, &KeyColor, &Console)>,
) {
    let root_console = &mut **root_console;
    root_console.clear(Some((0, 0, 0, 255)), None, Some(' ' as u16));
    for x in 0..root_console.get_width() as i32 {
        for y in 0..root_console.get_height() as i32 {
            root_console.back(
                x,
                y,
                if (x + y) & 1 == 1 {
                    (96, 64, 32, 255)
                } else {
                    (32, 64, 96, 255)
                },
            );
        }
    }
    root_console.print(
        (root_console.get_width() / 2) as i32,
        (root_console.get_height() / 2) as i32,
        "You create offscreen consoles\nand blit them on other consoles",
        TextAlign::Center,
        Some((255, 255, 255, 255)),
        None,
    );

    for (position, alpha, key_color, console) in console_query.iter() {
        let alpha = if alpha.inverted {
            1.0 - alpha.value
        } else {
            alpha.value
        };
        console.0.blit(
            position.x,
            position.y,
            root_console,
            alpha,
            alpha,
            key_color.0,
        );
    }
}
examples/perf.rs (line 45)
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
fn render(
    mut root_console: ResMut<RootConsole>,
    mut perf_test: ResMut<PerfTest>,
    fps_info: Res<FpsInfo>,
) {
    let fps = fps_info.fps;
    let con_width = root_console.get_width();
    let con_height = root_console.get_height();
    for y in 0..con_height as i32 {
        for x in 0..con_width as i32 {
            let val = perf_test.rnd();
            root_console.back(
                x,
                y,
                (
                    (val & 0xFF) as u8,
                    ((val >> 8) & 0x5F) as u8,
                    ((val >> 16) & 0x3F) as u8,
                    255,
                ),
            );
            root_console.fore(
                x,
                y,
                (
                    ((val >> 16) & 0xFF) as u8,
                    ((val >> 24) & 0xFF) as u8,
                    ((val >> 32) & 0xFF) as u8,
                    255,
                ),
            );
            root_console.ascii(x, y, ((val >> 40) & 0xFF) as u16);
        }
    }
    root_console.rectangle(
        (con_width / 2 - 10) as i32,
        (con_height / 2 - 2) as i32,
        20,
        5,
        Some((255, 255, 255, 255)),
        Some((0, 0, 0, 255)),
        Some(' ' as u16),
    );
    root_console.print(
        (con_width / 2) as i32,
        (con_height / 2) as i32,
        &format!("{} fps", fps),
        TextAlign::Center,
        Some((255, 255, 255, 255)),
        None,
    );
}
source

pub fn get_height(&self) -> u32

Examples found in repository?
examples/demo/level.rs (line 207)
205
206
207
208
209
210
fn render_loading_level(mut root_console: ResMut<RootConsole>) {
    let x = (root_console.get_width() / 2) as i32;
    let y = (root_console.get_height() / 2) as i32;

    root_console.print_color(x, y, "#[white]Loading#[red]...", TextAlign::Center, None);
}
More examples
Hide additional examples
examples/lowfps.rs (line 39)
35
36
37
38
39
40
41
42
43
44
45
46
47
48
fn render(fps: Res<FpsInfo>, mut root_console: ResMut<RootConsole>) {
    let fps = fps.fps;

    let x = (root_console.get_width() / 2) as i32;
    let y = (root_console.get_height() / 2) as i32;

    root_console.print_color(
        x,
        y,
        &format!("Frames since last second : #[red]{}", fps),
        TextAlign::Center,
        None,
    );
}
examples/image.rs (line 59)
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
fn render(mut root_console: ResMut<RootConsole>, mut skull: NonSendMut<SkullImage>) {
    let root_console = &mut **root_console;
    let skull = &mut *skull;
    let scale = skull.scale_time.cos();
    root_console.clear(None, Some((0, 0, 0, 255)), None);
    skull.skull.blit_ex(
        root_console,
        (root_console.get_width() / 2) as f32,
        (root_console.get_height() / 2) as f32,
        scale,
        scale,
        skull.angle,
        None,
    );
}
examples/alpha.rs (line 78)
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
fn update_circle(
    root_console: Res<RootConsole>,
    entities: Res<Entities>,
    mut circle_query: Query<(&mut Position, &mut Radius, &mut Angle, &Circle)>,
) {
    let (mut position, mut radius, mut angle, _) = circle_query.get_mut(entities.circle).unwrap();

    // update the circle radius and center position
    angle.0 += 0.6;
    radius.0 = 10.0 + 3.0 * (angle.0 / 10.0).sin();
    let cs = (angle.0 / 20.0).cos();
    let sn = (angle.0 / 15.0).sin();
    position.x = (root_console.get_width() / 2) as f32 + cs * 15.0;
    position.y = (root_console.get_height() / 2) as f32 + sn * 15.0;
}
examples/blit.rs (line 119)
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
fn update_position_and_speed(
    root_console: Res<RootConsole>,
    step: Res<Step>,
    mut position_speed_query: Query<(&mut Position, &mut Speed)>,
) {
    if step.0 == 0 {
        for (mut position, mut speed) in position_speed_query.iter_mut() {
            let size = (
                root_console.get_width() as i32,
                root_console.get_height() as i32,
            );
            position.x += speed.x;
            if position.x == size.0 - 20 || position.x == 0 {
                speed.x = -speed.x;
            }
            position.y += speed.y;
            if position.y == size.1 - 20 || position.y == 0 {
                speed.y = -speed.y;
            }
        }
    }
}

fn update_alpha(mut console_query: Query<(&mut Alpha, &Console)>) {
    for (mut alpha, _) in console_query.iter_mut() {
        if alpha.value <= 0.0 || alpha.value >= 1.0 {
            alpha.step = -alpha.step;
        }
        alpha.value += alpha.step;
    }
}

fn update_step(mut step: ResMut<Step>) {
    step.0 = (step.0 + 1) % 10;
}

fn render(
    mut root_console: ResMut<RootConsole>,
    console_query: Query<(&Position, &Alpha, &KeyColor, &Console)>,
) {
    let root_console = &mut **root_console;
    root_console.clear(Some((0, 0, 0, 255)), None, Some(' ' as u16));
    for x in 0..root_console.get_width() as i32 {
        for y in 0..root_console.get_height() as i32 {
            root_console.back(
                x,
                y,
                if (x + y) & 1 == 1 {
                    (96, 64, 32, 255)
                } else {
                    (32, 64, 96, 255)
                },
            );
        }
    }
    root_console.print(
        (root_console.get_width() / 2) as i32,
        (root_console.get_height() / 2) as i32,
        "You create offscreen consoles\nand blit them on other consoles",
        TextAlign::Center,
        Some((255, 255, 255, 255)),
        None,
    );

    for (position, alpha, key_color, console) in console_query.iter() {
        let alpha = if alpha.inverted {
            1.0 - alpha.value
        } else {
            alpha.value
        };
        console.0.blit(
            position.x,
            position.y,
            root_console,
            alpha,
            alpha,
            key_color.0,
        );
    }
}
examples/perf.rs (line 46)
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
fn render(
    mut root_console: ResMut<RootConsole>,
    mut perf_test: ResMut<PerfTest>,
    fps_info: Res<FpsInfo>,
) {
    let fps = fps_info.fps;
    let con_width = root_console.get_width();
    let con_height = root_console.get_height();
    for y in 0..con_height as i32 {
        for x in 0..con_width as i32 {
            let val = perf_test.rnd();
            root_console.back(
                x,
                y,
                (
                    (val & 0xFF) as u8,
                    ((val >> 8) & 0x5F) as u8,
                    ((val >> 16) & 0x3F) as u8,
                    255,
                ),
            );
            root_console.fore(
                x,
                y,
                (
                    ((val >> 16) & 0xFF) as u8,
                    ((val >> 24) & 0xFF) as u8,
                    ((val >> 32) & 0xFF) as u8,
                    255,
                ),
            );
            root_console.ascii(x, y, ((val >> 40) & 0xFF) as u16);
        }
    }
    root_console.rectangle(
        (con_width / 2 - 10) as i32,
        (con_height / 2 - 2) as i32,
        20,
        5,
        Some((255, 255, 255, 255)),
        Some((0, 0, 0, 255)),
        Some(' ' as u16),
    );
    root_console.print(
        (con_width / 2) as i32,
        (con_height / 2) as i32,
        &format!("{} fps", fps),
        TextAlign::Center,
        Some((255, 255, 255, 255)),
        None,
    );
}
source

pub fn get_size(&self) -> (u32, u32)

source

pub fn get_pot_width(&self) -> u32

source

pub fn get_pot_height(&self) -> u32

source

pub fn borrow_ascii(&self) -> &Vec<u32>

for fast reading of the characters values

source

pub fn borrow_foreground(&self) -> &Vec<(u8, u8, u8, u8)>

for fast reading of the characters colors

source

pub fn borrow_background(&self) -> &Vec<(u8, u8, u8, u8)>

for fast reading of the background colors

source

pub fn borrow_mut_ascii(&mut self) -> &mut Vec<u32>

for fast writing of the characters values

source

pub fn borrow_mut_foreground(&mut self) -> &mut Vec<(u8, u8, u8, u8)>

for fast writing of the characters colors

source

pub fn borrow_mut_background(&mut self) -> &mut Vec<(u8, u8, u8, u8)>

for fast writing of the background colors

source

pub fn get_back(&self, x: i32, y: i32) -> Option<(u8, u8, u8, u8)>

get the background color of a cell (if x,y inside the console)

source

pub fn get_fore(&self, x: i32, y: i32) -> Option<(u8, u8, u8, u8)>

get the foreground color of a cell (if x,y inside the console)

source

pub fn get_ascii(&self, x: i32, y: i32) -> Option<u16>

get the ascii code of a cell (if x,y inside the console)

source

pub fn unsafe_get_back(&self, x: i32, y: i32) -> (u8, u8, u8, u8)

get the background color of a cell (no boundary check)

source

pub fn unsafe_get_fore(&self, x: i32, y: i32) -> (u8, u8, u8, u8)

get the foreground color of a cell (no boundary check)

source

pub fn unsafe_get_ascii(&self, x: i32, y: i32) -> u16

get the ascii code of a cell (no boundary check)

source

pub fn ascii(&mut self, x: i32, y: i32, ascii: u16)

set the character at a specific position (doesn’t change the color).

Since the glyph associated with an ascii code depends on the font you’re using, doryen-rs can’t provide constants for specific characters except for a few ones used internally.

More information about this here.

You can find some constants that work with most fonts in this file provided by Alex Mooney.

Examples found in repository?
examples/demo/player.rs (lines 100-104)
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
fn render_player(
    mut root_console: ResMut<RootConsole>,
    light_map: NonSend<LightMap>,
    query: Query<&Position, With<Player>>,
) {
    let player_position = query.single();
    let light = light_map
        .0
        .pixel(player_position.x as u32, player_position.y as u32)
        .unwrap();
    root_console.ascii(
        player_position.character_x(),
        player_position.character_y(),
        '@' as u16,
    );
    root_console.fore(
        player_position.character_x(),
        player_position.character_y(),
        light,
    );
}
More examples
Hide additional examples
examples/demo/shared/character.rs (lines 60-64)
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
fn render_character(
    mut root_console: ResMut<RootConsole>,
    query: Query<(&Character, &Position)>,
    level_map: Res<LevelMap>,
    light_map: NonSend<LightMap>,
) {
    for (character, position) in &query {
        if !level_map
            .0
            .is_in_fov(position.x as usize, position.y as usize)
        {
            continue;
        }
        let (color, penumbra) = if character.light {
            (character.color, false)
        } else {
            let light = light_map
                .0
                .pixel(position.x as u32, position.y as u32)
                .unwrap();

            let penumbra = is_penumbra(light, 100);
            let mut color = color_mul(character.color, light);
            if penumbra {
                color = color_scale(color, LIGHT_COEF);
            }
            (color, penumbra)
        };
        root_console.ascii(
            position.character_x(),
            position.character_y(),
            if penumbra { '?' as u16 } else { character.ch },
        );
        root_console.fore(position.character_x(), position.character_y(), color);
    }
}
examples/fonts.rs (lines 103-107)
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
fn render(mut root_console: ResMut<RootConsole>, font: Res<Font>) {
    root_console.rectangle(
        0,
        0,
        CONSOLE_WIDTH,
        CONSOLE_HEIGHT,
        Some((128, 128, 128, 255)),
        None,
        Some('.' as u16),
    );
    root_console.area(
        10,
        10,
        5,
        5,
        Some((255, 64, 64, 255)),
        Some((128, 32, 32, 255)),
        Some('&' as u16),
    );
    root_console.ascii(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT / 2 - 10) as i32,
        '@' as u16,
    );
    root_console.fore(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT / 2 - 10) as i32,
        (255, 255, 255, 255),
    );
    root_console.rectangle(
        (CONSOLE_WIDTH / 2 - 20) as i32,
        (CONSOLE_HEIGHT / 2 - 2) as i32,
        40,
        7,
        Some((255, 255, 255, 255)),
        Some((0, 0, 0, 255)),
        Some(' ' as u16),
    );
    root_console.print(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT / 2) as i32,
        font.current_font_name,
        TextAlign::Center,
        Some((255, 255, 255, 255)),
        None,
    );
    root_console.print(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT / 2) as i32 + 2,
        "PageUp/PageDown to change font",
        TextAlign::Center,
        Some((255, 192, 128, 255)),
        None,
    );
}
examples/perf.rs (line 70)
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
fn render(
    mut root_console: ResMut<RootConsole>,
    mut perf_test: ResMut<PerfTest>,
    fps_info: Res<FpsInfo>,
) {
    let fps = fps_info.fps;
    let con_width = root_console.get_width();
    let con_height = root_console.get_height();
    for y in 0..con_height as i32 {
        for x in 0..con_width as i32 {
            let val = perf_test.rnd();
            root_console.back(
                x,
                y,
                (
                    (val & 0xFF) as u8,
                    ((val >> 8) & 0x5F) as u8,
                    ((val >> 16) & 0x3F) as u8,
                    255,
                ),
            );
            root_console.fore(
                x,
                y,
                (
                    ((val >> 16) & 0xFF) as u8,
                    ((val >> 24) & 0xFF) as u8,
                    ((val >> 32) & 0xFF) as u8,
                    255,
                ),
            );
            root_console.ascii(x, y, ((val >> 40) & 0xFF) as u16);
        }
    }
    root_console.rectangle(
        (con_width / 2 - 10) as i32,
        (con_height / 2 - 2) as i32,
        20,
        5,
        Some((255, 255, 255, 255)),
        Some((0, 0, 0, 255)),
        Some(' ' as u16),
    );
    root_console.print(
        (con_width / 2) as i32,
        (con_height / 2) as i32,
        &format!("{} fps", fps),
        TextAlign::Center,
        Some((255, 255, 255, 255)),
        None,
    );
}
examples/basic.rs (line 163)
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
fn render(
    entities: Res<Entities>,
    mut root_console: ResMut<RootConsole>,
    player_query: Query<(&Position<i32>, &Player)>,
    mouse_query: Query<(&Position<f32>, &Mouse)>,
) {
    root_console.rectangle(
        0,
        0,
        CONSOLE_WIDTH,
        CONSOLE_HEIGHT,
        Some((128, 128, 128, 255)),
        Some((0, 0, 0, 255)),
        Some('.' as u16),
    );
    root_console.area(
        10,
        10,
        5,
        5,
        Some((255, 64, 64, 255)),
        Some((128, 32, 32, 255)),
        Some('&' as u16),
    );

    let (player_position, _) = player_query.get(entities.player).unwrap();

    root_console.ascii(player_position.x, player_position.y, '@' as u16);
    root_console.fore(player_position.x, player_position.y, (255, 255, 255, 255));
    root_console.print_color(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT - 1) as i32,
        "#[red]arrows#[white] : move - #[red]CTRL-S#[white] : save screenshot",
        TextAlign::Center,
        None,
    );

    let (mouse_position, _) = mouse_query.get(entities.mouse).unwrap();

    root_console.print_color(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT - 3) as i32,
        &format!(
            "#[white]Mouse coordinates: #[red]{}, {}",
            mouse_position.x, mouse_position.y
        ),
        TextAlign::Center,
        None,
    );
    root_console.print_color(
        5,
        5,
        "#[blue]This blue text contains a #[red]red#[] word",
        TextAlign::Left,
        None,
    );
    root_console.back(
        mouse_position.x as i32,
        mouse_position.y as i32,
        (255, 255, 255, 255),
    );
}
source

pub fn fore(&mut self, x: i32, y: i32, col: (u8, u8, u8, u8))

set the character color at a specific position

Examples found in repository?
examples/demo/player.rs (lines 105-109)
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
fn render_player(
    mut root_console: ResMut<RootConsole>,
    light_map: NonSend<LightMap>,
    query: Query<&Position, With<Player>>,
) {
    let player_position = query.single();
    let light = light_map
        .0
        .pixel(player_position.x as u32, player_position.y as u32)
        .unwrap();
    root_console.ascii(
        player_position.character_x(),
        player_position.character_y(),
        '@' as u16,
    );
    root_console.fore(
        player_position.character_x(),
        player_position.character_y(),
        light,
    );
}
More examples
Hide additional examples
examples/demo/shared/character.rs (line 65)
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
fn render_character(
    mut root_console: ResMut<RootConsole>,
    query: Query<(&Character, &Position)>,
    level_map: Res<LevelMap>,
    light_map: NonSend<LightMap>,
) {
    for (character, position) in &query {
        if !level_map
            .0
            .is_in_fov(position.x as usize, position.y as usize)
        {
            continue;
        }
        let (color, penumbra) = if character.light {
            (character.color, false)
        } else {
            let light = light_map
                .0
                .pixel(position.x as u32, position.y as u32)
                .unwrap();

            let penumbra = is_penumbra(light, 100);
            let mut color = color_mul(character.color, light);
            if penumbra {
                color = color_scale(color, LIGHT_COEF);
            }
            (color, penumbra)
        };
        root_console.ascii(
            position.character_x(),
            position.character_y(),
            if penumbra { '?' as u16 } else { character.ch },
        );
        root_console.fore(position.character_x(), position.character_y(), color);
    }
}
examples/fonts.rs (lines 108-112)
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
fn render(mut root_console: ResMut<RootConsole>, font: Res<Font>) {
    root_console.rectangle(
        0,
        0,
        CONSOLE_WIDTH,
        CONSOLE_HEIGHT,
        Some((128, 128, 128, 255)),
        None,
        Some('.' as u16),
    );
    root_console.area(
        10,
        10,
        5,
        5,
        Some((255, 64, 64, 255)),
        Some((128, 32, 32, 255)),
        Some('&' as u16),
    );
    root_console.ascii(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT / 2 - 10) as i32,
        '@' as u16,
    );
    root_console.fore(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT / 2 - 10) as i32,
        (255, 255, 255, 255),
    );
    root_console.rectangle(
        (CONSOLE_WIDTH / 2 - 20) as i32,
        (CONSOLE_HEIGHT / 2 - 2) as i32,
        40,
        7,
        Some((255, 255, 255, 255)),
        Some((0, 0, 0, 255)),
        Some(' ' as u16),
    );
    root_console.print(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT / 2) as i32,
        font.current_font_name,
        TextAlign::Center,
        Some((255, 255, 255, 255)),
        None,
    );
    root_console.print(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT / 2) as i32 + 2,
        "PageUp/PageDown to change font",
        TextAlign::Center,
        Some((255, 192, 128, 255)),
        None,
    );
}
examples/perf.rs (lines 60-69)
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
fn render(
    mut root_console: ResMut<RootConsole>,
    mut perf_test: ResMut<PerfTest>,
    fps_info: Res<FpsInfo>,
) {
    let fps = fps_info.fps;
    let con_width = root_console.get_width();
    let con_height = root_console.get_height();
    for y in 0..con_height as i32 {
        for x in 0..con_width as i32 {
            let val = perf_test.rnd();
            root_console.back(
                x,
                y,
                (
                    (val & 0xFF) as u8,
                    ((val >> 8) & 0x5F) as u8,
                    ((val >> 16) & 0x3F) as u8,
                    255,
                ),
            );
            root_console.fore(
                x,
                y,
                (
                    ((val >> 16) & 0xFF) as u8,
                    ((val >> 24) & 0xFF) as u8,
                    ((val >> 32) & 0xFF) as u8,
                    255,
                ),
            );
            root_console.ascii(x, y, ((val >> 40) & 0xFF) as u16);
        }
    }
    root_console.rectangle(
        (con_width / 2 - 10) as i32,
        (con_height / 2 - 2) as i32,
        20,
        5,
        Some((255, 255, 255, 255)),
        Some((0, 0, 0, 255)),
        Some(' ' as u16),
    );
    root_console.print(
        (con_width / 2) as i32,
        (con_height / 2) as i32,
        &format!("{} fps", fps),
        TextAlign::Center,
        Some((255, 255, 255, 255)),
        None,
    );
}
examples/basic.rs (line 164)
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
fn render(
    entities: Res<Entities>,
    mut root_console: ResMut<RootConsole>,
    player_query: Query<(&Position<i32>, &Player)>,
    mouse_query: Query<(&Position<f32>, &Mouse)>,
) {
    root_console.rectangle(
        0,
        0,
        CONSOLE_WIDTH,
        CONSOLE_HEIGHT,
        Some((128, 128, 128, 255)),
        Some((0, 0, 0, 255)),
        Some('.' as u16),
    );
    root_console.area(
        10,
        10,
        5,
        5,
        Some((255, 64, 64, 255)),
        Some((128, 32, 32, 255)),
        Some('&' as u16),
    );

    let (player_position, _) = player_query.get(entities.player).unwrap();

    root_console.ascii(player_position.x, player_position.y, '@' as u16);
    root_console.fore(player_position.x, player_position.y, (255, 255, 255, 255));
    root_console.print_color(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT - 1) as i32,
        "#[red]arrows#[white] : move - #[red]CTRL-S#[white] : save screenshot",
        TextAlign::Center,
        None,
    );

    let (mouse_position, _) = mouse_query.get(entities.mouse).unwrap();

    root_console.print_color(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT - 3) as i32,
        &format!(
            "#[white]Mouse coordinates: #[red]{}, {}",
            mouse_position.x, mouse_position.y
        ),
        TextAlign::Center,
        None,
    );
    root_console.print_color(
        5,
        5,
        "#[blue]This blue text contains a #[red]red#[] word",
        TextAlign::Left,
        None,
    );
    root_console.back(
        mouse_position.x as i32,
        mouse_position.y as i32,
        (255, 255, 255, 255),
    );
}
source

pub fn back(&mut self, x: i32, y: i32, col: (u8, u8, u8, u8))

set the background color at a specific position

Examples found in repository?
examples/resize.rs (lines 79-83)
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
fn render(mut root_console: ResMut<RootConsole>, resize_data: Res<ResizeData>) {
    root_console.rectangle(
        0,
        0,
        resize_data.width,
        resize_data.height,
        Some((128, 128, 128, 255)),
        Some((0, 0, 0, 255)),
        Some(' ' as u16),
    );
    root_console.area(
        10,
        10,
        5,
        5,
        Some((255, 64, 64, 255)),
        Some((128, 32, 32, 255)),
        Some('&' as u16),
    );
    root_console.print(
        (resize_data.width / 2) as i32,
        (resize_data.height / 2) as i32,
        &format!("{} x {}", resize_data.width, resize_data.height),
        TextAlign::Center,
        None,
        None,
    );
    root_console.back(
        resize_data.mouse_pos.0 as i32,
        resize_data.mouse_pos.1 as i32,
        (255, 255, 255, 255),
    );
}
More examples
Hide additional examples
examples/alpha.rs (line 97)
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
fn render(
    entities: Res<Entities>,
    mut root_console: ResMut<RootConsole>,
    circle_query: Query<(&Position, &Radius, &Angle, &Circle)>,
) {
    // fill the console with transparent black. The more opaque it is, the faster the previous frames will fade to black.
    // replace alpha with a lower value, like 10 or 5 and the effect will last longer.
    root_console.clear(None, Some((0, 0, 0, 20)), None);
    let (position, radius, angle, _) = circle_query.get(entities.circle).unwrap();
    // here we render current frame (only a circle of blue dots)
    for r in 0..10 {
        let angle = angle.0 + r as f32 * std::f32::consts::PI * 2.0 / 10.0;
        let cs = angle.cos();
        let sn = angle.sin();
        let x = position.x + radius.0 * cs;
        let y = position.y + radius.0 * sn;
        root_console.back(x as i32, y as i32, (0, 0, 255, 255));
    }
}
examples/blit.rs (line 70)
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
fn init(mut commands: Commands) {
    let mut c1 = DoryenConsole::new(20, 20);
    let mut c2 = DoryenConsole::new(20, 20);
    for y in 0..20 {
        for x in 0..20 {
            c1.back(x, y, (((x + y * 10) % 255) as u8, 0, 0, 255));
            c2.back(
                x,
                y,
                if (x - 10) * (x - 10) + (y - 10) * (y - 10) < 100 {
                    (255, 192, 32, 255 - x as u8 * 10)
                } else {
                    (0, 0, 0, 255)
                },
            );
        }
    }
    c1.print(10, 10, "Hello", TextAlign::Center, None, None);
    c2.print(10, 10, "Circle", TextAlign::Center, None, None);

    commands.spawn(ConsoleBundle {
        console: Console(c1),
        position: Position { x: 5, y: 5 },
        speed: Speed { x: 1, y: 1 },
        alpha: Alpha {
            value: 1.0,
            step: 0.01,
            inverted: false,
        },
        key_color: KeyColor(None),
    });

    commands.spawn(ConsoleBundle {
        console: Console(c2),
        position: Position { x: 15, y: 20 },
        speed: Speed { x: -1, y: 1 },
        alpha: Alpha {
            value: 1.0,
            step: 0.01,
            inverted: true,
        },
        key_color: KeyColor(Some((0, 0, 0, 255))),
    });
}

fn update_position_and_speed(
    root_console: Res<RootConsole>,
    step: Res<Step>,
    mut position_speed_query: Query<(&mut Position, &mut Speed)>,
) {
    if step.0 == 0 {
        for (mut position, mut speed) in position_speed_query.iter_mut() {
            let size = (
                root_console.get_width() as i32,
                root_console.get_height() as i32,
            );
            position.x += speed.x;
            if position.x == size.0 - 20 || position.x == 0 {
                speed.x = -speed.x;
            }
            position.y += speed.y;
            if position.y == size.1 - 20 || position.y == 0 {
                speed.y = -speed.y;
            }
        }
    }
}

fn update_alpha(mut console_query: Query<(&mut Alpha, &Console)>) {
    for (mut alpha, _) in console_query.iter_mut() {
        if alpha.value <= 0.0 || alpha.value >= 1.0 {
            alpha.step = -alpha.step;
        }
        alpha.value += alpha.step;
    }
}

fn update_step(mut step: ResMut<Step>) {
    step.0 = (step.0 + 1) % 10;
}

fn render(
    mut root_console: ResMut<RootConsole>,
    console_query: Query<(&Position, &Alpha, &KeyColor, &Console)>,
) {
    let root_console = &mut **root_console;
    root_console.clear(Some((0, 0, 0, 255)), None, Some(' ' as u16));
    for x in 0..root_console.get_width() as i32 {
        for y in 0..root_console.get_height() as i32 {
            root_console.back(
                x,
                y,
                if (x + y) & 1 == 1 {
                    (96, 64, 32, 255)
                } else {
                    (32, 64, 96, 255)
                },
            );
        }
    }
    root_console.print(
        (root_console.get_width() / 2) as i32,
        (root_console.get_height() / 2) as i32,
        "You create offscreen consoles\nand blit them on other consoles",
        TextAlign::Center,
        Some((255, 255, 255, 255)),
        None,
    );

    for (position, alpha, key_color, console) in console_query.iter() {
        let alpha = if alpha.inverted {
            1.0 - alpha.value
        } else {
            alpha.value
        };
        console.0.blit(
            position.x,
            position.y,
            root_console,
            alpha,
            alpha,
            key_color.0,
        );
    }
}
examples/perf.rs (lines 50-59)
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
fn render(
    mut root_console: ResMut<RootConsole>,
    mut perf_test: ResMut<PerfTest>,
    fps_info: Res<FpsInfo>,
) {
    let fps = fps_info.fps;
    let con_width = root_console.get_width();
    let con_height = root_console.get_height();
    for y in 0..con_height as i32 {
        for x in 0..con_width as i32 {
            let val = perf_test.rnd();
            root_console.back(
                x,
                y,
                (
                    (val & 0xFF) as u8,
                    ((val >> 8) & 0x5F) as u8,
                    ((val >> 16) & 0x3F) as u8,
                    255,
                ),
            );
            root_console.fore(
                x,
                y,
                (
                    ((val >> 16) & 0xFF) as u8,
                    ((val >> 24) & 0xFF) as u8,
                    ((val >> 32) & 0xFF) as u8,
                    255,
                ),
            );
            root_console.ascii(x, y, ((val >> 40) & 0xFF) as u16);
        }
    }
    root_console.rectangle(
        (con_width / 2 - 10) as i32,
        (con_height / 2 - 2) as i32,
        20,
        5,
        Some((255, 255, 255, 255)),
        Some((0, 0, 0, 255)),
        Some(' ' as u16),
    );
    root_console.print(
        (con_width / 2) as i32,
        (con_height / 2) as i32,
        &format!("{} fps", fps),
        TextAlign::Center,
        Some((255, 255, 255, 255)),
        None,
    );
}
examples/basic.rs (lines 192-196)
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
fn render(
    entities: Res<Entities>,
    mut root_console: ResMut<RootConsole>,
    player_query: Query<(&Position<i32>, &Player)>,
    mouse_query: Query<(&Position<f32>, &Mouse)>,
) {
    root_console.rectangle(
        0,
        0,
        CONSOLE_WIDTH,
        CONSOLE_HEIGHT,
        Some((128, 128, 128, 255)),
        Some((0, 0, 0, 255)),
        Some('.' as u16),
    );
    root_console.area(
        10,
        10,
        5,
        5,
        Some((255, 64, 64, 255)),
        Some((128, 32, 32, 255)),
        Some('&' as u16),
    );

    let (player_position, _) = player_query.get(entities.player).unwrap();

    root_console.ascii(player_position.x, player_position.y, '@' as u16);
    root_console.fore(player_position.x, player_position.y, (255, 255, 255, 255));
    root_console.print_color(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT - 1) as i32,
        "#[red]arrows#[white] : move - #[red]CTRL-S#[white] : save screenshot",
        TextAlign::Center,
        None,
    );

    let (mouse_position, _) = mouse_query.get(entities.mouse).unwrap();

    root_console.print_color(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT - 3) as i32,
        &format!(
            "#[white]Mouse coordinates: #[red]{}, {}",
            mouse_position.x, mouse_position.y
        ),
        TextAlign::Center,
        None,
    );
    root_console.print_color(
        5,
        5,
        "#[blue]This blue text contains a #[red]red#[] word",
        TextAlign::Left,
        None,
    );
    root_console.back(
        mouse_position.x as i32,
        mouse_position.y as i32,
        (255, 255, 255, 255),
    );
}
source

pub fn unsafe_ascii(&mut self, x: i32, y: i32, ascii: u16)

set the character at a specific position (no boundary check)

source

pub fn unsafe_fore(&mut self, x: i32, y: i32, col: (u8, u8, u8, u8))

set the character color at a specific position (no boundary check)

source

pub fn unsafe_back(&mut self, x: i32, y: i32, col: (u8, u8, u8, u8))

set the background color at a specific position (no boundary check)

source

pub fn clear( &mut self, fore: Option<(u8, u8, u8, u8)>, back: Option<(u8, u8, u8, u8)>, fillchar: Option<u16> )

fill the whole console with values

Examples found in repository?
examples/demo/main.rs (line 108)
107
108
109
fn clear(mut root_console: ResMut<RootConsole>) {
    root_console.clear(Some(BLACK), Some(BLACK), Some(' ' as u16));
}
More examples
Hide additional examples
examples/subcell.rs (line 42)
41
42
43
44
45
46
47
48
49
50
51
52
53
54
fn render(mut root_console: ResMut<RootConsole>, mut skull: NonSendMut<SkullImage>) {
    root_console.clear(None, Some((0, 0, 0, 255)), None);
    skull
        .skull
        .blit_2x(&mut root_console, 23, 0, 0, 0, None, None, None);
    root_console.print(
        40,
        4,
        "Those pixels\nare twice smaller\nthan a console cell.\nMagic!",
        TextAlign::Center,
        Some((0, 0, 0, 255)),
        None,
    );
}
examples/image.rs (line 55)
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
fn render(mut root_console: ResMut<RootConsole>, mut skull: NonSendMut<SkullImage>) {
    let root_console = &mut **root_console;
    let skull = &mut *skull;
    let scale = skull.scale_time.cos();
    root_console.clear(None, Some((0, 0, 0, 255)), None);
    skull.skull.blit_ex(
        root_console,
        (root_console.get_width() / 2) as f32,
        (root_console.get_height() / 2) as f32,
        scale,
        scale,
        skull.angle,
        None,
    );
}
examples/text_input.rs (line 54)
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
fn render(mut root_console: ResMut<RootConsole>, text_input: Res<TextInput>) {
    root_console.clear(None, None, Some(' ' as u16));
    root_console.print(
        5,
        5,
        &format!(
            "Type some text : {}{}",
            text_input.text,
            // blinking cursor
            if text_input.cursor % 25 < 12 {
                '_'
            } else {
                ' '
            }
        ),
        TextAlign::Left,
        Some(WHITE),
        None,
    );
}
examples/exit.rs (line 45)
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
fn render(mut root_console: ResMut<RootConsole>, close_requested: Res<CloseRequested>) {
    root_console.clear(None, None, Some(' ' as u16));
    if close_requested.0 {
        root_console.print(
            5,
            5,
            "Exit game ? (press Y or N)",
            TextAlign::Left,
            Some(WHITE),
            None,
        );
    } else {
        root_console.print(
            5,
            5,
            "Press ESC to exit (on web, this does nothing)",
            TextAlign::Left,
            Some(WHITE),
            None,
        );
    }
}
examples/alpha.rs (line 88)
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
fn render(
    entities: Res<Entities>,
    mut root_console: ResMut<RootConsole>,
    circle_query: Query<(&Position, &Radius, &Angle, &Circle)>,
) {
    // fill the console with transparent black. The more opaque it is, the faster the previous frames will fade to black.
    // replace alpha with a lower value, like 10 or 5 and the effect will last longer.
    root_console.clear(None, Some((0, 0, 0, 20)), None);
    let (position, radius, angle, _) = circle_query.get(entities.circle).unwrap();
    // here we render current frame (only a circle of blue dots)
    for r in 0..10 {
        let angle = angle.0 + r as f32 * std::f32::consts::PI * 2.0 / 10.0;
        let cs = angle.cos();
        let sn = angle.sin();
        let x = position.x + radius.0 * cs;
        let y = position.y + radius.0 * sn;
        root_console.back(x as i32, y as i32, (0, 0, 255, 255));
    }
}
source

pub fn print_color( &mut self, x: i32, y: i32, text: &str, align: TextAlign, back: Option<(u8, u8, u8, u8)> )

write a multi-color string. Foreground color is defined by #[color_name] patterns inside the string. color_name must have been registered with Console::register_color before. Default foreground color is white, at the start of the string. When an unknown color name is used, the color goes back to its previous value. You can then use an empty name to end a color span. Example

use doryen_rs::{Console, TextAlign};
let mut con=Console::new(80,25);
con.register_color("pink", (255, 0, 255, 255));
con.register_color("blue", (0, 0, 255, 255));
con.print_color(5, 5, "#[blue]This blue text contains a #[pink]pink#[] word", TextAlign::Left, None);
Examples found in repository?
examples/demo/level.rs (line 209)
205
206
207
208
209
210
fn render_loading_level(mut root_console: ResMut<RootConsole>) {
    let x = (root_console.get_width() / 2) as i32;
    let y = (root_console.get_height() / 2) as i32;

    root_console.print_color(x, y, "#[white]Loading#[red]...", TextAlign::Center, None);
}
More examples
Hide additional examples
examples/lowfps.rs (lines 41-47)
35
36
37
38
39
40
41
42
43
44
45
46
47
48
fn render(fps: Res<FpsInfo>, mut root_console: ResMut<RootConsole>) {
    let fps = fps.fps;

    let x = (root_console.get_width() / 2) as i32;
    let y = (root_console.get_height() / 2) as i32;

    root_console.print_color(
        x,
        y,
        &format!("Frames since last second : #[red]{}", fps),
        TextAlign::Center,
        None,
    );
}
examples/demo/main.rs (lines 112-121)
111
112
113
114
115
116
117
118
119
120
121
122
fn render_instructions(mut root_console: ResMut<RootConsole>, fps: Res<FpsInfo>) {
    root_console.print_color(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT - 2) as i32,
        &format!(
            "#[white]Move with #[red]arrows or WSAD #[white]Fire with #[red]mouse   {:4} fps",
            fps.fps
        ),
        TextAlign::Center,
        None,
    );
}
examples/basic.rs (lines 165-171)
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
fn render(
    entities: Res<Entities>,
    mut root_console: ResMut<RootConsole>,
    player_query: Query<(&Position<i32>, &Player)>,
    mouse_query: Query<(&Position<f32>, &Mouse)>,
) {
    root_console.rectangle(
        0,
        0,
        CONSOLE_WIDTH,
        CONSOLE_HEIGHT,
        Some((128, 128, 128, 255)),
        Some((0, 0, 0, 255)),
        Some('.' as u16),
    );
    root_console.area(
        10,
        10,
        5,
        5,
        Some((255, 64, 64, 255)),
        Some((128, 32, 32, 255)),
        Some('&' as u16),
    );

    let (player_position, _) = player_query.get(entities.player).unwrap();

    root_console.ascii(player_position.x, player_position.y, '@' as u16);
    root_console.fore(player_position.x, player_position.y, (255, 255, 255, 255));
    root_console.print_color(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT - 1) as i32,
        "#[red]arrows#[white] : move - #[red]CTRL-S#[white] : save screenshot",
        TextAlign::Center,
        None,
    );

    let (mouse_position, _) = mouse_query.get(entities.mouse).unwrap();

    root_console.print_color(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT - 3) as i32,
        &format!(
            "#[white]Mouse coordinates: #[red]{}, {}",
            mouse_position.x, mouse_position.y
        ),
        TextAlign::Center,
        None,
    );
    root_console.print_color(
        5,
        5,
        "#[blue]This blue text contains a #[red]red#[] word",
        TextAlign::Left,
        None,
    );
    root_console.back(
        mouse_position.x as i32,
        mouse_position.y as i32,
        (255, 255, 255, 255),
    );
}
source

pub fn print( &mut self, x: i32, y: i32, text: &str, align: TextAlign, fore: Option<(u8, u8, u8, u8)>, back: Option<(u8, u8, u8, u8)> )

write a string. If the string reaches the border of the console, it’s truncated. If the string contains carriage return "\n", multiple lines are printed.

Examples found in repository?
examples/subcell.rs (lines 46-53)
41
42
43
44
45
46
47
48
49
50
51
52
53
54
fn render(mut root_console: ResMut<RootConsole>, mut skull: NonSendMut<SkullImage>) {
    root_console.clear(None, Some((0, 0, 0, 255)), None);
    skull
        .skull
        .blit_2x(&mut root_console, 23, 0, 0, 0, None, None, None);
    root_console.print(
        40,
        4,
        "Those pixels\nare twice smaller\nthan a console cell.\nMagic!",
        TextAlign::Center,
        Some((0, 0, 0, 255)),
        None,
    );
}
More examples
Hide additional examples
examples/text_input.rs (lines 55-71)
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
fn render(mut root_console: ResMut<RootConsole>, text_input: Res<TextInput>) {
    root_console.clear(None, None, Some(' ' as u16));
    root_console.print(
        5,
        5,
        &format!(
            "Type some text : {}{}",
            text_input.text,
            // blinking cursor
            if text_input.cursor % 25 < 12 {
                '_'
            } else {
                ' '
            }
        ),
        TextAlign::Left,
        Some(WHITE),
        None,
    );
}
examples/exit.rs (lines 47-54)
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
fn render(mut root_console: ResMut<RootConsole>, close_requested: Res<CloseRequested>) {
    root_console.clear(None, None, Some(' ' as u16));
    if close_requested.0 {
        root_console.print(
            5,
            5,
            "Exit game ? (press Y or N)",
            TextAlign::Left,
            Some(WHITE),
            None,
        );
    } else {
        root_console.print(
            5,
            5,
            "Press ESC to exit (on web, this does nothing)",
            TextAlign::Left,
            Some(WHITE),
            None,
        );
    }
}
examples/resize.rs (lines 71-78)
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
fn render(mut root_console: ResMut<RootConsole>, resize_data: Res<ResizeData>) {
    root_console.rectangle(
        0,
        0,
        resize_data.width,
        resize_data.height,
        Some((128, 128, 128, 255)),
        Some((0, 0, 0, 255)),
        Some(' ' as u16),
    );
    root_console.area(
        10,
        10,
        5,
        5,
        Some((255, 64, 64, 255)),
        Some((128, 32, 32, 255)),
        Some('&' as u16),
    );
    root_console.print(
        (resize_data.width / 2) as i32,
        (resize_data.height / 2) as i32,
        &format!("{} x {}", resize_data.width, resize_data.height),
        TextAlign::Center,
        None,
        None,
    );
    root_console.back(
        resize_data.mouse_pos.0 as i32,
        resize_data.mouse_pos.1 as i32,
        (255, 255, 255, 255),
    );
}
examples/blit.rs (line 82)
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
fn init(mut commands: Commands) {
    let mut c1 = DoryenConsole::new(20, 20);
    let mut c2 = DoryenConsole::new(20, 20);
    for y in 0..20 {
        for x in 0..20 {
            c1.back(x, y, (((x + y * 10) % 255) as u8, 0, 0, 255));
            c2.back(
                x,
                y,
                if (x - 10) * (x - 10) + (y - 10) * (y - 10) < 100 {
                    (255, 192, 32, 255 - x as u8 * 10)
                } else {
                    (0, 0, 0, 255)
                },
            );
        }
    }
    c1.print(10, 10, "Hello", TextAlign::Center, None, None);
    c2.print(10, 10, "Circle", TextAlign::Center, None, None);

    commands.spawn(ConsoleBundle {
        console: Console(c1),
        position: Position { x: 5, y: 5 },
        speed: Speed { x: 1, y: 1 },
        alpha: Alpha {
            value: 1.0,
            step: 0.01,
            inverted: false,
        },
        key_color: KeyColor(None),
    });

    commands.spawn(ConsoleBundle {
        console: Console(c2),
        position: Position { x: 15, y: 20 },
        speed: Speed { x: -1, y: 1 },
        alpha: Alpha {
            value: 1.0,
            step: 0.01,
            inverted: true,
        },
        key_color: KeyColor(Some((0, 0, 0, 255))),
    });
}

fn update_position_and_speed(
    root_console: Res<RootConsole>,
    step: Res<Step>,
    mut position_speed_query: Query<(&mut Position, &mut Speed)>,
) {
    if step.0 == 0 {
        for (mut position, mut speed) in position_speed_query.iter_mut() {
            let size = (
                root_console.get_width() as i32,
                root_console.get_height() as i32,
            );
            position.x += speed.x;
            if position.x == size.0 - 20 || position.x == 0 {
                speed.x = -speed.x;
            }
            position.y += speed.y;
            if position.y == size.1 - 20 || position.y == 0 {
                speed.y = -speed.y;
            }
        }
    }
}

fn update_alpha(mut console_query: Query<(&mut Alpha, &Console)>) {
    for (mut alpha, _) in console_query.iter_mut() {
        if alpha.value <= 0.0 || alpha.value >= 1.0 {
            alpha.step = -alpha.step;
        }
        alpha.value += alpha.step;
    }
}

fn update_step(mut step: ResMut<Step>) {
    step.0 = (step.0 + 1) % 10;
}

fn render(
    mut root_console: ResMut<RootConsole>,
    console_query: Query<(&Position, &Alpha, &KeyColor, &Console)>,
) {
    let root_console = &mut **root_console;
    root_console.clear(Some((0, 0, 0, 255)), None, Some(' ' as u16));
    for x in 0..root_console.get_width() as i32 {
        for y in 0..root_console.get_height() as i32 {
            root_console.back(
                x,
                y,
                if (x + y) & 1 == 1 {
                    (96, 64, 32, 255)
                } else {
                    (32, 64, 96, 255)
                },
            );
        }
    }
    root_console.print(
        (root_console.get_width() / 2) as i32,
        (root_console.get_height() / 2) as i32,
        "You create offscreen consoles\nand blit them on other consoles",
        TextAlign::Center,
        Some((255, 255, 255, 255)),
        None,
    );

    for (position, alpha, key_color, console) in console_query.iter() {
        let alpha = if alpha.inverted {
            1.0 - alpha.value
        } else {
            alpha.value
        };
        console.0.blit(
            position.x,
            position.y,
            root_console,
            alpha,
            alpha,
            key_color.0,
        );
    }
}
examples/fonts.rs (lines 122-129)
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
fn render(mut root_console: ResMut<RootConsole>, font: Res<Font>) {
    root_console.rectangle(
        0,
        0,
        CONSOLE_WIDTH,
        CONSOLE_HEIGHT,
        Some((128, 128, 128, 255)),
        None,
        Some('.' as u16),
    );
    root_console.area(
        10,
        10,
        5,
        5,
        Some((255, 64, 64, 255)),
        Some((128, 32, 32, 255)),
        Some('&' as u16),
    );
    root_console.ascii(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT / 2 - 10) as i32,
        '@' as u16,
    );
    root_console.fore(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT / 2 - 10) as i32,
        (255, 255, 255, 255),
    );
    root_console.rectangle(
        (CONSOLE_WIDTH / 2 - 20) as i32,
        (CONSOLE_HEIGHT / 2 - 2) as i32,
        40,
        7,
        Some((255, 255, 255, 255)),
        Some((0, 0, 0, 255)),
        Some(' ' as u16),
    );
    root_console.print(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT / 2) as i32,
        font.current_font_name,
        TextAlign::Center,
        Some((255, 255, 255, 255)),
        None,
    );
    root_console.print(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT / 2) as i32 + 2,
        "PageUp/PageDown to change font",
        TextAlign::Center,
        Some((255, 192, 128, 255)),
        None,
    );
}
source

pub fn rectangle( &mut self, x: i32, y: i32, w: u32, h: u32, fore: Option<(u8, u8, u8, u8)>, back: Option<(u8, u8, u8, u8)>, fill: Option<u16> )

draw a rectangle, possibly filling it with a character.

Examples found in repository?
examples/resize.rs (lines 53-61)
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
fn render(mut root_console: ResMut<RootConsole>, resize_data: Res<ResizeData>) {
    root_console.rectangle(
        0,
        0,
        resize_data.width,
        resize_data.height,
        Some((128, 128, 128, 255)),
        Some((0, 0, 0, 255)),
        Some(' ' as u16),
    );
    root_console.area(
        10,
        10,
        5,
        5,
        Some((255, 64, 64, 255)),
        Some((128, 32, 32, 255)),
        Some('&' as u16),
    );
    root_console.print(
        (resize_data.width / 2) as i32,
        (resize_data.height / 2) as i32,
        &format!("{} x {}", resize_data.width, resize_data.height),
        TextAlign::Center,
        None,
        None,
    );
    root_console.back(
        resize_data.mouse_pos.0 as i32,
        resize_data.mouse_pos.1 as i32,
        (255, 255, 255, 255),
    );
}
More examples
Hide additional examples
examples/fonts.rs (lines 85-93)
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
fn render(mut root_console: ResMut<RootConsole>, font: Res<Font>) {
    root_console.rectangle(
        0,
        0,
        CONSOLE_WIDTH,
        CONSOLE_HEIGHT,
        Some((128, 128, 128, 255)),
        None,
        Some('.' as u16),
    );
    root_console.area(
        10,
        10,
        5,
        5,
        Some((255, 64, 64, 255)),
        Some((128, 32, 32, 255)),
        Some('&' as u16),
    );
    root_console.ascii(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT / 2 - 10) as i32,
        '@' as u16,
    );
    root_console.fore(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT / 2 - 10) as i32,
        (255, 255, 255, 255),
    );
    root_console.rectangle(
        (CONSOLE_WIDTH / 2 - 20) as i32,
        (CONSOLE_HEIGHT / 2 - 2) as i32,
        40,
        7,
        Some((255, 255, 255, 255)),
        Some((0, 0, 0, 255)),
        Some(' ' as u16),
    );
    root_console.print(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT / 2) as i32,
        font.current_font_name,
        TextAlign::Center,
        Some((255, 255, 255, 255)),
        None,
    );
    root_console.print(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT / 2) as i32 + 2,
        "PageUp/PageDown to change font",
        TextAlign::Center,
        Some((255, 192, 128, 255)),
        None,
    );
}
examples/perf.rs (lines 73-81)
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
fn render(
    mut root_console: ResMut<RootConsole>,
    mut perf_test: ResMut<PerfTest>,
    fps_info: Res<FpsInfo>,
) {
    let fps = fps_info.fps;
    let con_width = root_console.get_width();
    let con_height = root_console.get_height();
    for y in 0..con_height as i32 {
        for x in 0..con_width as i32 {
            let val = perf_test.rnd();
            root_console.back(
                x,
                y,
                (
                    (val & 0xFF) as u8,
                    ((val >> 8) & 0x5F) as u8,
                    ((val >> 16) & 0x3F) as u8,
                    255,
                ),
            );
            root_console.fore(
                x,
                y,
                (
                    ((val >> 16) & 0xFF) as u8,
                    ((val >> 24) & 0xFF) as u8,
                    ((val >> 32) & 0xFF) as u8,
                    255,
                ),
            );
            root_console.ascii(x, y, ((val >> 40) & 0xFF) as u16);
        }
    }
    root_console.rectangle(
        (con_width / 2 - 10) as i32,
        (con_height / 2 - 2) as i32,
        20,
        5,
        Some((255, 255, 255, 255)),
        Some((0, 0, 0, 255)),
        Some(' ' as u16),
    );
    root_console.print(
        (con_width / 2) as i32,
        (con_height / 2) as i32,
        &format!("{} fps", fps),
        TextAlign::Center,
        Some((255, 255, 255, 255)),
        None,
    );
}
examples/basic.rs (lines 142-150)
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
fn render(
    entities: Res<Entities>,
    mut root_console: ResMut<RootConsole>,
    player_query: Query<(&Position<i32>, &Player)>,
    mouse_query: Query<(&Position<f32>, &Mouse)>,
) {
    root_console.rectangle(
        0,
        0,
        CONSOLE_WIDTH,
        CONSOLE_HEIGHT,
        Some((128, 128, 128, 255)),
        Some((0, 0, 0, 255)),
        Some('.' as u16),
    );
    root_console.area(
        10,
        10,
        5,
        5,
        Some((255, 64, 64, 255)),
        Some((128, 32, 32, 255)),
        Some('&' as u16),
    );

    let (player_position, _) = player_query.get(entities.player).unwrap();

    root_console.ascii(player_position.x, player_position.y, '@' as u16);
    root_console.fore(player_position.x, player_position.y, (255, 255, 255, 255));
    root_console.print_color(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT - 1) as i32,
        "#[red]arrows#[white] : move - #[red]CTRL-S#[white] : save screenshot",
        TextAlign::Center,
        None,
    );

    let (mouse_position, _) = mouse_query.get(entities.mouse).unwrap();

    root_console.print_color(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT - 3) as i32,
        &format!(
            "#[white]Mouse coordinates: #[red]{}, {}",
            mouse_position.x, mouse_position.y
        ),
        TextAlign::Center,
        None,
    );
    root_console.print_color(
        5,
        5,
        "#[blue]This blue text contains a #[red]red#[] word",
        TextAlign::Left,
        None,
    );
    root_console.back(
        mouse_position.x as i32,
        mouse_position.y as i32,
        (255, 255, 255, 255),
    );
}
source

pub fn area( &mut self, x: i32, y: i32, w: u32, h: u32, fore: Option<(u8, u8, u8, u8)>, back: Option<(u8, u8, u8, u8)>, fillchar: Option<u16> )

fill an area with values

Examples found in repository?
examples/resize.rs (lines 62-70)
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
fn render(mut root_console: ResMut<RootConsole>, resize_data: Res<ResizeData>) {
    root_console.rectangle(
        0,
        0,
        resize_data.width,
        resize_data.height,
        Some((128, 128, 128, 255)),
        Some((0, 0, 0, 255)),
        Some(' ' as u16),
    );
    root_console.area(
        10,
        10,
        5,
        5,
        Some((255, 64, 64, 255)),
        Some((128, 32, 32, 255)),
        Some('&' as u16),
    );
    root_console.print(
        (resize_data.width / 2) as i32,
        (resize_data.height / 2) as i32,
        &format!("{} x {}", resize_data.width, resize_data.height),
        TextAlign::Center,
        None,
        None,
    );
    root_console.back(
        resize_data.mouse_pos.0 as i32,
        resize_data.mouse_pos.1 as i32,
        (255, 255, 255, 255),
    );
}
More examples
Hide additional examples
examples/fonts.rs (lines 94-102)
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
fn render(mut root_console: ResMut<RootConsole>, font: Res<Font>) {
    root_console.rectangle(
        0,
        0,
        CONSOLE_WIDTH,
        CONSOLE_HEIGHT,
        Some((128, 128, 128, 255)),
        None,
        Some('.' as u16),
    );
    root_console.area(
        10,
        10,
        5,
        5,
        Some((255, 64, 64, 255)),
        Some((128, 32, 32, 255)),
        Some('&' as u16),
    );
    root_console.ascii(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT / 2 - 10) as i32,
        '@' as u16,
    );
    root_console.fore(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT / 2 - 10) as i32,
        (255, 255, 255, 255),
    );
    root_console.rectangle(
        (CONSOLE_WIDTH / 2 - 20) as i32,
        (CONSOLE_HEIGHT / 2 - 2) as i32,
        40,
        7,
        Some((255, 255, 255, 255)),
        Some((0, 0, 0, 255)),
        Some(' ' as u16),
    );
    root_console.print(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT / 2) as i32,
        font.current_font_name,
        TextAlign::Center,
        Some((255, 255, 255, 255)),
        None,
    );
    root_console.print(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT / 2) as i32 + 2,
        "PageUp/PageDown to change font",
        TextAlign::Center,
        Some((255, 192, 128, 255)),
        None,
    );
}
examples/basic.rs (lines 151-159)
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
fn render(
    entities: Res<Entities>,
    mut root_console: ResMut<RootConsole>,
    player_query: Query<(&Position<i32>, &Player)>,
    mouse_query: Query<(&Position<f32>, &Mouse)>,
) {
    root_console.rectangle(
        0,
        0,
        CONSOLE_WIDTH,
        CONSOLE_HEIGHT,
        Some((128, 128, 128, 255)),
        Some((0, 0, 0, 255)),
        Some('.' as u16),
    );
    root_console.area(
        10,
        10,
        5,
        5,
        Some((255, 64, 64, 255)),
        Some((128, 32, 32, 255)),
        Some('&' as u16),
    );

    let (player_position, _) = player_query.get(entities.player).unwrap();

    root_console.ascii(player_position.x, player_position.y, '@' as u16);
    root_console.fore(player_position.x, player_position.y, (255, 255, 255, 255));
    root_console.print_color(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT - 1) as i32,
        "#[red]arrows#[white] : move - #[red]CTRL-S#[white] : save screenshot",
        TextAlign::Center,
        None,
    );

    let (mouse_position, _) = mouse_query.get(entities.mouse).unwrap();

    root_console.print_color(
        (CONSOLE_WIDTH / 2) as i32,
        (CONSOLE_HEIGHT - 3) as i32,
        &format!(
            "#[white]Mouse coordinates: #[red]{}, {}",
            mouse_position.x, mouse_position.y
        ),
        TextAlign::Center,
        None,
    );
    root_console.print_color(
        5,
        5,
        "#[blue]This blue text contains a #[red]red#[] word",
        TextAlign::Left,
        None,
    );
    root_console.back(
        mouse_position.x as i32,
        mouse_position.y as i32,
        (255, 255, 255, 255),
    );
}
source

pub fn cell( &mut self, x: i32, y: i32, ascii: Option<u16>, fore: Option<(u8, u8, u8, u8)>, back: Option<(u8, u8, u8, u8)> )

can change all properties of a console cell at once

source

pub fn blit( &self, x: i32, y: i32, destination: &mut Console, fore_alpha: f32, back_alpha: f32, key_color: Option<(u8, u8, u8, u8)> )

blit (draw) a console onto another one You can use fore_alpha and back_alpha to blend this console with existing background on the destination. If you define a key color, the cells using this color as background will be ignored. This makes it possible to blit non rectangular zones.

Examples found in repository?
examples/blit.rs (lines 180-187)
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
fn render(
    mut root_console: ResMut<RootConsole>,
    console_query: Query<(&Position, &Alpha, &KeyColor, &Console)>,
) {
    let root_console = &mut **root_console;
    root_console.clear(Some((0, 0, 0, 255)), None, Some(' ' as u16));
    for x in 0..root_console.get_width() as i32 {
        for y in 0..root_console.get_height() as i32 {
            root_console.back(
                x,
                y,
                if (x + y) & 1 == 1 {
                    (96, 64, 32, 255)
                } else {
                    (32, 64, 96, 255)
                },
            );
        }
    }
    root_console.print(
        (root_console.get_width() / 2) as i32,
        (root_console.get_height() / 2) as i32,
        "You create offscreen consoles\nand blit them on other consoles",
        TextAlign::Center,
        Some((255, 255, 255, 255)),
        None,
    );

    for (position, alpha, key_color, console) in console_query.iter() {
        let alpha = if alpha.inverted {
            1.0 - alpha.value
        } else {
            alpha.value
        };
        console.0.blit(
            position.x,
            position.y,
            root_console,
            alpha,
            alpha,
            key_color.0,
        );
    }
}
source

pub fn blit_ex( &self, xsrc: i32, ysrc: i32, wsrc: i32, hsrc: i32, destination: &mut Console, xdst: i32, ydst: i32, fore_alpha: f32, back_alpha: f32, key_color: Option<(u8, u8, u8, u8)> )

blit a region of this console onto another one. see Console::blit

Trait Implementations§

source§

impl Debug for RootConsole

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for RootConsole

source§

fn default() -> RootConsole

Returns the “default value” for a type. Read more
source§

impl Deref for RootConsole

§

type Target = Console

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl DerefMut for RootConsole

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl Resource for RootConsole
where Self: Send + Sync + 'static,

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromWorld for T
where T: Default,

source§

fn from_world(_world: &mut World) -> T

Creates Self using data from the given World.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more