[−][src]Struct doryen_rs::Console
This contains the data for a console (including the one displayed on the screen) and methods to draw on it.
Methods
impl Console
[src]
pub fn new(width: u32, height: u32) -> Self
[src]
create a new offscreen console that you can blit on another console width and height are in cells (characters), not pixels.
pub fn resize(&mut self, width: u32, height: u32)
[src]
resizes the console
pub fn register_color(&mut self, name: &str, value: Color)
[src]
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);
pub fn get_width(&self) -> u32
[src]
pub fn get_height(&self) -> u32
[src]
pub fn get_pot_width(&self) -> u32
[src]
pub fn get_pot_height(&self) -> u32
[src]
pub fn borrow_ascii(&self) -> &Vec<u32>
[src]
for fast reading of the characters values
pub fn borrow_foreground(&self) -> &Vec<Color>
[src]
for fast reading of the characters colors
pub fn borrow_background(&self) -> &Vec<Color>
[src]
for fast reading of the background colors
pub fn borrow_mut_ascii(&mut self) -> &mut Vec<u32>
[src]
for fast writing of the characters values
pub fn borrow_mut_foreground(&mut self) -> &mut Vec<Color>
[src]
for fast writing of the characters colors
pub fn borrow_mut_background(&mut self) -> &mut Vec<Color>
[src]
for fast writing of the background colors
pub fn get_back(&self, x: i32, y: i32) -> Option<Color>
[src]
get the background color of a cell (if x,y inside the console)
pub fn get_fore(&self, x: i32, y: i32) -> Option<Color>
[src]
get the foreground color of a cell (if x,y inside the console)
pub fn get_ascii(&self, x: i32, y: i32) -> Option<u16>
[src]
get the ascii code of a cell (if x,y inside the console)
pub fn unsafe_get_back(&self, x: i32, y: i32) -> Color
[src]
get the background color of a cell (no boundary check)
pub fn unsafe_get_fore(&self, x: i32, y: i32) -> Color
[src]
get the foreground color of a cell (no boundary check)
pub fn unsafe_get_ascii(&self, x: i32, y: i32) -> u16
[src]
get the ascii code of a cell (no boundary check)
pub fn ascii(&mut self, x: i32, y: i32, ascii: u16)
[src]
set the character at a specific position (doesn't change the color)
pub fn fore(&mut self, x: i32, y: i32, col: Color)
[src]
set the character color at a specific position
pub fn back(&mut self, x: i32, y: i32, col: Color)
[src]
set the background color at a specific position
pub fn unsafe_ascii(&mut self, x: i32, y: i32, ascii: u16)
[src]
set the character at a specific position (no boundary check)
pub fn unsafe_fore(&mut self, x: i32, y: i32, col: Color)
[src]
set the character color at a specific position (no boundary check)
pub fn unsafe_back(&mut self, x: i32, y: i32, col: Color)
[src]
set the background color at a specific position (no boundary check)
pub fn clear(
&mut self,
fore: Option<Color>,
back: Option<Color>,
fillchar: Option<u16>
)
[src]
&mut self,
fore: Option<Color>,
back: Option<Color>,
fillchar: Option<u16>
)
fill the whole console with values
pub fn print_color(
&mut self,
x: i32,
y: i32,
text: &str,
align: TextAlign,
back: Option<Color>
)
[src]
&mut self,
x: i32,
y: i32,
text: &str,
align: TextAlign,
back: Option<Color>
)
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);
pub fn print(
&mut self,
x: i32,
y: i32,
text: &str,
align: TextAlign,
fore: Option<Color>,
back: Option<Color>
)
[src]
&mut self,
x: i32,
y: i32,
text: &str,
align: TextAlign,
fore: Option<Color>,
back: Option<Color>
)
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.
pub fn rectangle(
&mut self,
x: i32,
y: i32,
w: u32,
h: u32,
fore: Option<Color>,
back: Option<Color>,
fill: Option<u16>
)
[src]
&mut self,
x: i32,
y: i32,
w: u32,
h: u32,
fore: Option<Color>,
back: Option<Color>,
fill: Option<u16>
)
draw a rectangle, possibly filling it with a character.
pub fn area(
&mut self,
x: i32,
y: i32,
w: u32,
h: u32,
fore: Option<Color>,
back: Option<Color>,
fillchar: Option<u16>
)
[src]
&mut self,
x: i32,
y: i32,
w: u32,
h: u32,
fore: Option<Color>,
back: Option<Color>,
fillchar: Option<u16>
)
fill an area with values
pub fn cell(
&mut self,
x: i32,
y: i32,
ascii: Option<u16>,
fore: Option<Color>,
back: Option<Color>
)
[src]
&mut self,
x: i32,
y: i32,
ascii: Option<u16>,
fore: Option<Color>,
back: Option<Color>
)
can change all properties of a console cell at once
pub fn blit(
&self,
x: i32,
y: i32,
destination: &mut Console,
fore_alpha: f32,
back_alpha: f32,
key_color: Option<Color>
)
[src]
&self,
x: i32,
y: i32,
destination: &mut Console,
fore_alpha: f32,
back_alpha: f32,
key_color: Option<Color>
)
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.
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<Color>
)
[src]
&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<Color>
)
blit a region of this console onto another one.
see Console::blit
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Erased for T
impl<T> Downcast for T where
T: Any,
T: Any,