Struct bracket_terminal::prelude::BTerm
source · [−]pub struct BTerm {Show 19 fields
pub width_pixels: u32,
pub height_pixels: u32,
pub original_height_pixels: u32,
pub original_width_pixels: u32,
pub fps: f32,
pub frame_time_ms: f32,
pub active_console: usize,
pub key: Option<VirtualKeyCode>,
pub mouse_pos: (i32, i32),
pub left_click: bool,
pub shift: bool,
pub control: bool,
pub alt: bool,
pub web_button: Option<String>,
pub quitting: bool,
pub post_scanlines: bool,
pub post_screenburn: bool,
pub screen_burn_color: RGB,
pub mouse_visible: bool,
}
Expand description
A BTerm context.
Fields
width_pixels: u32
height_pixels: u32
original_height_pixels: u32
original_width_pixels: u32
fps: f32
frame_time_ms: f32
active_console: usize
key: Option<VirtualKeyCode>
mouse_pos: (i32, i32)
left_click: bool
shift: bool
control: bool
alt: bool
quitting: bool
post_scanlines: bool
post_screenburn: bool
screen_burn_color: RGB
mouse_visible: bool
Implementations
sourceimpl BTerm
impl BTerm
sourcepub fn init_raw<S: ToString, T>(
width_pixels: T,
height_pixels: T,
window_title: S,
platform_hints: InitHints
) -> BResult<BTerm>where
T: TryInto<u32>,
pub fn init_raw<S: ToString, T>(
width_pixels: T,
height_pixels: T,
window_title: S,
platform_hints: InitHints
) -> BResult<BTerm>where
T: TryInto<u32>,
Initializes an OpenGL context and a window, stores the info in the BTerm structure.
sourcepub fn init_simple8x8<S: ToString, T>(
width_chars: T,
height_chars: T,
window_title: S,
path_to_shaders: S
) -> BTermwhere
T: TryInto<u32>,
👎Deprecated since 0.6.2: Please migrate to the BTermBuilder system instead.
pub fn init_simple8x8<S: ToString, T>(
width_chars: T,
height_chars: T,
window_title: S,
path_to_shaders: S
) -> BTermwhere
T: TryInto<u32>,
Quick initialization for when you just want an 8x8 font terminal
sourcepub fn init_simple8x16<S: ToString, T>(
width_chars: T,
height_chars: T,
window_title: S,
path_to_shaders: S
) -> BTermwhere
T: TryInto<u32>,
👎Deprecated since 0.6.2: Please migrate to the BTermBuilder system instead.
pub fn init_simple8x16<S: ToString, T>(
width_chars: T,
height_chars: T,
window_title: S,
path_to_shaders: S
) -> BTermwhere
T: TryInto<u32>,
Quick initialization for when you just want an 8x16 VGA font terminal
sourcepub fn register_console(
&mut self,
new_console: Box<dyn Console>,
font_index: usize
) -> usize
pub fn register_console(
&mut self,
new_console: Box<dyn Console>,
font_index: usize
) -> usize
Registers a new console terminal for output, and returns its handle number.
sourcepub fn register_console_no_bg(
&mut self,
new_console: Box<dyn Console>,
font_index: usize
) -> usize
pub fn register_console_no_bg(
&mut self,
new_console: Box<dyn Console>,
font_index: usize
) -> usize
Registers a new console terminal for output, and returns its handle number. This variant requests that the new console not render background colors, so it can be layered on top of other consoles.
sourcepub fn register_fancy_console(
&mut self,
new_console: Box<dyn Console>,
font_index: usize
) -> usize
pub fn register_fancy_console(
&mut self,
new_console: Box<dyn Console>,
font_index: usize
) -> usize
Registers a new console terminal for output, and returns its handle number. This variant requests that the new console not render background colors, so it can be layered on top of other consoles.
sourcepub fn register_sprite_console(&mut self, new_console: Box<dyn Console>) -> usize
pub fn register_sprite_console(&mut self, new_console: Box<dyn Console>) -> usize
Registers a new Sprite-based console
sourcepub fn set_active_console(&mut self, id: usize)
pub fn set_active_console(&mut self, id: usize)
Sets the currently active console number.
sourcepub fn mouse_pos(&self) -> (i32, i32)
pub fn mouse_pos(&self) -> (i32, i32)
Applies the current physical mouse position to the active console, and translates the coordinates into that console’s coordinate space.
sourcepub fn mouse_point(&self) -> Point
pub fn mouse_point(&self) -> Point
Applies the current physical mouse position to the active console, and translates the coordinates into that console’s coordinate space.
sourcepub fn render_xp_sprite(&mut self, xp: &XpFile, x: i32, y: i32)
pub fn render_xp_sprite(&mut self, xp: &XpFile, x: i32, y: i32)
Render a REX Paint (https://www.gridsagegames.com/rexpaint/) file as a sprite. The sprite will be offset by offset_x and offset_y. Transparent cells will not be rendered.
sourcepub fn to_xp_file(&self, width: usize, height: usize) -> XpFile
pub fn to_xp_file(&self, width: usize, height: usize) -> XpFile
Saves the entire console stack to a REX Paint XP file. If your consoles are of
varying sizes, the file format supports it - but REX doesn’t. So you may want to
avoid that. You can also get individual layers with to_xp_layer
.
sourcepub fn with_post_scanlines(&mut self, with_burn: bool)
pub fn with_post_scanlines(&mut self, with_burn: bool)
Enable scanlines post-processing effect.
pub fn screen_burn_color(&mut self, color: RGB)
pub fn with_mouse_visibility(&mut self, with_visibility: bool)
sourceimpl BTerm
impl BTerm
Implements console-like BTerm. Note that this isn’t a Console trait anymore, due to the need for helper generics.
sourcepub fn get_char_size(&self) -> (u32, u32)
pub fn get_char_size(&self) -> (u32, u32)
Gets the active console’s size, in characters.
sourcepub fn cls_bg<COLOR>(&mut self, background: COLOR)where
COLOR: Into<RGBA>,
pub fn cls_bg<COLOR>(&mut self, background: COLOR)where
COLOR: Into<RGBA>,
Request that the active console clear itself to a specified background color. Has no effect on consoles that don’t have a background color.
sourcepub fn print<S, X, Y>(&mut self, x: X, y: Y, output: S)where
S: ToString,
X: TryInto<i32>,
Y: TryInto<i32>,
pub fn print<S, X, Y>(&mut self, x: X, y: Y, output: S)where
S: ToString,
X: TryInto<i32>,
Y: TryInto<i32>,
Print a string to the active console.
sourcepub fn print_color<S, COLOR, COLOR2, X, Y>(
&mut self,
x: X,
y: Y,
fg: COLOR,
bg: COLOR2,
output: S
)where
S: ToString,
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
X: TryInto<i32>,
Y: TryInto<i32>,
pub fn print_color<S, COLOR, COLOR2, X, Y>(
&mut self,
x: X,
y: Y,
fg: COLOR,
bg: COLOR2,
output: S
)where
S: ToString,
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
X: TryInto<i32>,
Y: TryInto<i32>,
Print a string to the active console, in color.
sourcepub fn set<COLOR, COLOR2, GLYPH, X, Y>(
&mut self,
x: X,
y: Y,
fg: COLOR,
bg: COLOR2,
glyph: GLYPH
)where
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
GLYPH: TryInto<FontCharType>,
X: TryInto<i32>,
Y: TryInto<i32>,
pub fn set<COLOR, COLOR2, GLYPH, X, Y>(
&mut self,
x: X,
y: Y,
fg: COLOR,
bg: COLOR2,
glyph: GLYPH
)where
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
GLYPH: TryInto<FontCharType>,
X: TryInto<i32>,
Y: TryInto<i32>,
Set a single tile located at x/y to the specified foreground/background colors, and glyph.
sourcepub fn set_fancy<COLOR, COLOR2, GLYPH, ANGLE>(
&mut self,
position: PointF,
z_order: i32,
rotation: ANGLE,
scale: PointF,
fg: COLOR,
bg: COLOR2,
glyph: GLYPH
)where
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
GLYPH: TryInto<FontCharType>,
ANGLE: Into<Radians>,
pub fn set_fancy<COLOR, COLOR2, GLYPH, ANGLE>(
&mut self,
position: PointF,
z_order: i32,
rotation: ANGLE,
scale: PointF,
fg: COLOR,
bg: COLOR2,
glyph: GLYPH
)where
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
GLYPH: TryInto<FontCharType>,
ANGLE: Into<Radians>,
Set a tile with “fancy” additional attributes
sourcepub fn set_bg<COLOR, X, Y>(&mut self, x: X, y: Y, bg: COLOR)where
COLOR: Into<RGBA>,
X: TryInto<i32>,
Y: TryInto<i32>,
pub fn set_bg<COLOR, X, Y>(&mut self, x: X, y: Y, bg: COLOR)where
COLOR: Into<RGBA>,
X: TryInto<i32>,
Y: TryInto<i32>,
Sets the background color only of a specified tile.
sourcepub fn draw_box<COLOR, COLOR2, X, Y, W, H>(
&mut self,
x: X,
y: Y,
width: W,
height: H,
fg: COLOR,
bg: COLOR2
)where
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
X: TryInto<i32>,
Y: TryInto<i32>,
W: TryInto<i32>,
H: TryInto<i32>,
pub fn draw_box<COLOR, COLOR2, X, Y, W, H>(
&mut self,
x: X,
y: Y,
width: W,
height: H,
fg: COLOR,
bg: COLOR2
)where
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
X: TryInto<i32>,
Y: TryInto<i32>,
W: TryInto<i32>,
H: TryInto<i32>,
Draws a filled box, with single line characters.
sourcepub fn draw_box_double<COLOR, COLOR2, X, Y, W, H>(
&mut self,
x: X,
y: Y,
width: W,
height: H,
fg: COLOR,
bg: COLOR2
)where
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
X: TryInto<i32>,
Y: TryInto<i32>,
W: TryInto<i32>,
H: TryInto<i32>,
pub fn draw_box_double<COLOR, COLOR2, X, Y, W, H>(
&mut self,
x: X,
y: Y,
width: W,
height: H,
fg: COLOR,
bg: COLOR2
)where
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
X: TryInto<i32>,
Y: TryInto<i32>,
W: TryInto<i32>,
H: TryInto<i32>,
Draws a filled box, with double line characters.
sourcepub fn draw_hollow_box<COLOR, COLOR2, X, Y, W, H>(
&mut self,
x: X,
y: Y,
width: W,
height: H,
fg: COLOR,
bg: COLOR2
)where
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
X: TryInto<i32>,
Y: TryInto<i32>,
W: TryInto<i32>,
H: TryInto<i32>,
pub fn draw_hollow_box<COLOR, COLOR2, X, Y, W, H>(
&mut self,
x: X,
y: Y,
width: W,
height: H,
fg: COLOR,
bg: COLOR2
)where
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
X: TryInto<i32>,
Y: TryInto<i32>,
W: TryInto<i32>,
H: TryInto<i32>,
Draws a single-line box, without filling in the center.
sourcepub fn draw_hollow_box_double<COLOR, COLOR2, X, Y, W, H>(
&mut self,
x: X,
y: Y,
width: W,
height: H,
fg: COLOR,
bg: COLOR2
)where
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
X: TryInto<i32>,
Y: TryInto<i32>,
W: TryInto<i32>,
H: TryInto<i32>,
pub fn draw_hollow_box_double<COLOR, COLOR2, X, Y, W, H>(
&mut self,
x: X,
y: Y,
width: W,
height: H,
fg: COLOR,
bg: COLOR2
)where
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
X: TryInto<i32>,
Y: TryInto<i32>,
W: TryInto<i32>,
H: TryInto<i32>,
Draws a double-line box, without filling in the contents.
sourcepub fn draw_bar_horizontal<COLOR, COLOR2, X, Y, W, N, MAX>(
&mut self,
x: X,
y: Y,
width: W,
n: N,
max: MAX,
fg: COLOR,
bg: COLOR2
)where
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
X: TryInto<i32>,
Y: TryInto<i32>,
W: TryInto<i32>,
N: TryInto<i32>,
MAX: TryInto<i32>,
pub fn draw_bar_horizontal<COLOR, COLOR2, X, Y, W, N, MAX>(
&mut self,
x: X,
y: Y,
width: W,
n: N,
max: MAX,
fg: COLOR,
bg: COLOR2
)where
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
X: TryInto<i32>,
Y: TryInto<i32>,
W: TryInto<i32>,
N: TryInto<i32>,
MAX: TryInto<i32>,
Draws a horizontal bar, suitable for health-bars or progress bars.
sourcepub fn draw_bar_vertical<COLOR, COLOR2, X, Y, H, N, MAX>(
&mut self,
x: X,
y: Y,
height: H,
n: N,
max: MAX,
fg: COLOR,
bg: COLOR2
)where
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
X: TryInto<i32>,
Y: TryInto<i32>,
H: TryInto<i32>,
N: TryInto<i32>,
MAX: TryInto<i32>,
pub fn draw_bar_vertical<COLOR, COLOR2, X, Y, H, N, MAX>(
&mut self,
x: X,
y: Y,
height: H,
n: N,
max: MAX,
fg: COLOR,
bg: COLOR2
)where
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
X: TryInto<i32>,
Y: TryInto<i32>,
H: TryInto<i32>,
N: TryInto<i32>,
MAX: TryInto<i32>,
Draws a vertical bar, suitable for health-bars or progress bars.
sourcepub fn fill_region<COLOR, COLOR2, GLYPH>(
&mut self,
target: Rect,
glyph: GLYPH,
fg: COLOR,
bg: COLOR2
)where
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
GLYPH: TryInto<FontCharType>,
pub fn fill_region<COLOR, COLOR2, GLYPH>(
&mut self,
target: Rect,
glyph: GLYPH,
fg: COLOR,
bg: COLOR2
)where
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
GLYPH: TryInto<FontCharType>,
Fills a target region with the specified color/glyph combo.
sourcepub fn print_centered<S, Y>(&mut self, y: Y, text: S)where
S: ToString,
Y: TryInto<i32>,
pub fn print_centered<S, Y>(&mut self, y: Y, text: S)where
S: ToString,
Y: TryInto<i32>,
Prints centered text, centered across the whole line
sourcepub fn print_color_centered<S, COLOR, COLOR2, Y>(
&mut self,
y: Y,
fg: COLOR,
bg: COLOR2,
text: S
)where
S: ToString,
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
Y: TryInto<i32>,
pub fn print_color_centered<S, COLOR, COLOR2, Y>(
&mut self,
y: Y,
fg: COLOR,
bg: COLOR2,
text: S
)where
S: ToString,
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
Y: TryInto<i32>,
Prints centered text, centered across the whole line - in color
sourcepub fn print_centered_at<S, X, Y>(&mut self, x: X, y: Y, text: S)where
S: ToString,
X: TryInto<i32>,
Y: TryInto<i32>,
pub fn print_centered_at<S, X, Y>(&mut self, x: X, y: Y, text: S)where
S: ToString,
X: TryInto<i32>,
Y: TryInto<i32>,
Prints text, centered on an arbitrary point
sourcepub fn print_color_centered_at<S, COLOR, COLOR2, X, Y>(
&mut self,
x: X,
y: Y,
fg: COLOR,
bg: COLOR2,
text: S
)where
S: ToString,
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
X: TryInto<i32>,
Y: TryInto<i32>,
pub fn print_color_centered_at<S, COLOR, COLOR2, X, Y>(
&mut self,
x: X,
y: Y,
fg: COLOR,
bg: COLOR2,
text: S
)where
S: ToString,
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
X: TryInto<i32>,
Y: TryInto<i32>,
Prints colored text, centered on an arbitrary point
sourcepub fn print_right<S, X, Y>(&mut self, x: X, y: Y, text: S)where
S: ToString,
X: TryInto<i32>,
Y: TryInto<i32>,
pub fn print_right<S, X, Y>(&mut self, x: X, y: Y, text: S)where
S: ToString,
X: TryInto<i32>,
Y: TryInto<i32>,
Prints right-aligned text
sourcepub fn print_color_right<S, COLOR, COLOR2, X, Y>(
&mut self,
x: X,
y: Y,
fg: COLOR,
bg: COLOR2,
text: S
)where
S: ToString,
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
X: TryInto<i32>,
Y: TryInto<i32>,
pub fn print_color_right<S, COLOR, COLOR2, X, Y>(
&mut self,
x: X,
y: Y,
fg: COLOR,
bg: COLOR2,
text: S
)where
S: ToString,
COLOR: Into<RGBA>,
COLOR2: Into<RGBA>,
X: TryInto<i32>,
Y: TryInto<i32>,
Prints right-aligned text, in color
sourcepub fn printer<S, X, Y>(
&mut self,
x: X,
y: Y,
output: S,
align: TextAlign,
background: Option<RGBA>
)where
S: ToString,
X: TryInto<i32>,
Y: TryInto<i32>,
pub fn printer<S, X, Y>(
&mut self,
x: X,
y: Y,
output: S,
align: TextAlign,
background: Option<RGBA>
)where
S: ToString,
X: TryInto<i32>,
Y: TryInto<i32>,
Print a colorized string with the color encoding defined inline. For example: printer(1, 1, “#[blue]This blue text contains a #[pink]pink#[] word”) You can get the same effect with a TextBlock, but this can be easier. Thanks to doryen_rs for the idea.
sourcepub fn to_xp_layer(&self) -> XpLayer
pub fn to_xp_layer(&self) -> XpLayer
Exports the current layer to a REX Paint file
sourcepub fn set_offset(&mut self, x: f32, y: f32)
pub fn set_offset(&mut self, x: f32, y: f32)
Sets the active offset for the current layer
sourcepub fn set_scale(&mut self, scale: f32, center_x: i32, center_y: i32)
pub fn set_scale(&mut self, scale: f32, center_x: i32, center_y: i32)
Sets the active scale for the current layer
sourcepub fn set_clipping(&mut self, clipping: Option<Rect>)
pub fn set_clipping(&mut self, clipping: Option<Rect>)
Permits the creation of an arbitrary clipping rectangle. It’s a really good idea to make sure that this rectangle is entirely valid.
sourcepub fn get_clipping(&self) -> Option<Rect>
pub fn get_clipping(&self) -> Option<Rect>
Returns the current arbitrary clipping rectangle, None if there isn’t one.
sourcepub fn set_all_fg_alpha(&mut self, alpha: f32)
pub fn set_all_fg_alpha(&mut self, alpha: f32)
Sets ALL tiles foreground alpha (only tiles that exist, in sparse consoles).
sourcepub fn set_all_bg_alpha(&mut self, alpha: f32)
pub fn set_all_bg_alpha(&mut self, alpha: f32)
Sets ALL tiles background alpha (only tiles that exist, in sparse consoles).
sourcepub fn set_all_alpha(&mut self, fg: f32, bg: f32)
pub fn set_all_alpha(&mut self, fg: f32, bg: f32)
Sets ALL tiles foreground alpha (only tiles that exist, in sparse consoles).
sourcepub fn set_translation_mode(
&mut self,
console: usize,
translation: CharacterTranslationMode
)
pub fn set_translation_mode(
&mut self,
console: usize,
translation: CharacterTranslationMode
)
Sets the character translation mode on a console
sourcepub fn set_active_font(
&mut self,
font_index: usize,
resize_to_natural_dimensions: bool
)
pub fn set_active_font(
&mut self,
font_index: usize,
resize_to_natural_dimensions: bool
)
Change the active font for the layer. DO NOT USE WITH AMETHYST YET.
sourcepub fn set_char_size(&mut self, width: u32, height: u32)
pub fn set_char_size(&mut self, width: u32, height: u32)
Manually override the character size for the current terminal. Use with caution!
sourcepub fn set_char_size_and_resize_window(&mut self, _width: u32, _height: u32)
pub fn set_char_size_and_resize_window(&mut self, _width: u32, _height: u32)
Manually override the character size for the current terminal. Use with caution!
sourcepub fn screenshot<S: ToString>(&mut self, filename: S)
pub fn screenshot<S: ToString>(&mut self, filename: S)
Take a screenshot - Native only
sourcepub fn register_spritesheet(&mut self, ss: SpriteSheet) -> usize
pub fn register_spritesheet(&mut self, ss: SpriteSheet) -> usize
Register a sprite sheet (OpenGL - native or WASM - only)