pub struct Console { /* private fields */ }
Expand description

This contains the data for a console (including the one displayed on the screen) and methods to draw on it.

Implementations

create a new offscreen console that you can blit on another console width and height are in cells (characters), not pixels.

resizes the console

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);

for fast reading of the characters values

for fast reading of the characters colors

for fast reading of the background colors

for fast writing of the characters values

for fast writing of the characters colors

for fast writing of the background colors

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

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

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

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

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

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

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.

set the character color at a specific position

set the background color at a specific position

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

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

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

fill the whole console with values

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);

compute the length of a string containing color codes. Example :

use doryen_rs::Console;
let len = Console::text_color_len("#[red]red text with a #[blue]blue#[] word");
assert_eq!(len, 25); // actual string : "red text with a blue word"
let len = Console::text_color_len("#[red]a\nb");
assert_eq!(len, 3); // actual string : "a\nb"
let len = Console::text_color_len("normal string");
assert_eq!(len, 13);

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.

draw a rectangle, possibly filling it with a character.

fill an area with values

can change all properties of a console cell at once

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.

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.