Struct 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§web_button: Option<String>§quitting: bool§post_scanlines: bool§post_screenburn: bool§screen_burn_color: RGB§mouse_visible: bool

Implementations§

Source§

impl BTerm

Source

pub fn init_raw<S, T>( width_pixels: T, height_pixels: T, window_title: S, platform_hints: InitHints, ) -> Result<BTerm, Box<dyn Error + Send + Sync>>
where S: ToString, T: TryInto<u32>,

Initializes an OpenGL context and a window, stores the info in the BTerm structure.

Source

pub fn init_simple8x8<S, T>( width_chars: T, height_chars: T, window_title: S, path_to_shaders: S, ) -> BTerm
where S: ToString, T: TryInto<u32>,

👎Deprecated since 0.6.2: Please migrate to the BTermBuilder system instead.

Quick initialization for when you just want an 8x8 font terminal

Source

pub fn init_simple8x16<S, T>( width_chars: T, height_chars: T, window_title: S, path_to_shaders: S, ) -> BTerm
where S: ToString, T: TryInto<u32>,

👎Deprecated since 0.6.2: Please migrate to the BTermBuilder system instead.

Quick initialization for when you just want an 8x16 VGA font terminal

Source

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.

Source

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.

Source

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.

Source

pub fn register_sprite_console( &mut self, new_console: Box<dyn Console>, ) -> usize

Registers a new Sprite-based console

Source

pub fn set_active_console(&mut self, id: usize)

Sets the currently active console number.

Source

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.

Source

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.

Source

pub fn quit(&mut self)

Tells the game to quit

Source

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.

Source

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.

Source

pub fn with_post_scanlines(&mut self, with_burn: bool)

Enable scanlines post-processing effect.

Source

pub fn screen_burn_color(&mut self, color: RGB)

Source

pub fn with_mouse_visibility(&mut self, with_visibility: bool)

Source§

impl BTerm

Implements console-like BTerm. Note that this isn’t a Console trait anymore, due to the need for helper generics.

Source

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

Gets the active console’s size, in characters.

Source

pub fn cls(&mut self)

Request that the active console clear itself to default values.

Source

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.

Source

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.

Source

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.

Source

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<u16>, X: TryInto<i32>, Y: TryInto<i32>,

Set a single tile located at x/y to the specified foreground/background colors, and glyph.

Source

pub fn set_fancy<COLOR, COLOR2, GLYPH, ANGLE>( &mut self, position: Vec2, z_order: i32, rotation: ANGLE, scale: Vec2, fg: COLOR, bg: COLOR2, glyph: GLYPH, )
where COLOR: Into<RGBA>, COLOR2: Into<RGBA>, GLYPH: TryInto<u16>, ANGLE: Into<Radians>,

Set a tile with “fancy” additional attributes

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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<u16>,

Fills a target region with the specified color/glyph combo.

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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.

Source

pub fn to_xp_layer(&self) -> XpLayer

Exports the current layer to a REX Paint file

Source

pub fn set_offset(&mut self, x: f32, y: f32)

Sets the active offset for the current layer

Source

pub fn set_scale(&mut self, scale: f32, center_x: i32, center_y: i32)

Sets the active scale for the current layer

Source

pub fn get_scale(&self) -> (f32, i32, i32)

Gets the active scale for the current layer

Source

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.

Source

pub fn get_clipping(&self) -> Option<Rect>

Returns the current arbitrary clipping rectangle, None if there isn’t one.

Source

pub fn set_all_fg_alpha(&mut self, alpha: f32)

Sets ALL tiles foreground alpha (only tiles that exist, in sparse consoles).

Source

pub fn set_all_bg_alpha(&mut self, alpha: f32)

Sets ALL tiles background alpha (only tiles that exist, in sparse consoles).

Source

pub fn set_all_alpha(&mut self, fg: f32, bg: f32)

Sets ALL tiles foreground alpha (only tiles that exist, in sparse consoles).

Source

pub fn set_translation_mode( &mut self, console: usize, translation: CharacterTranslationMode, )

Sets the character translation mode on a console

Source

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.

Source

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

Manually override the character size for the current terminal. Use with caution!

Source

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!

Source

pub fn screenshot<S>(&mut self, filename: S)
where S: ToString,

Take a screenshot - Native only

Source

pub fn register_spritesheet(&mut self, ss: SpriteSheet) -> usize

Register a sprite sheet (OpenGL - native or WASM - only)

Source

pub fn add_sprite( &mut self, destination: Rect, z_order: i32, tint: RGBA, index: usize, )

Add a sprite to the current console

Trait Implementations§

Source§

impl Clone for BTerm

Source§

fn clone(&self) -> BTerm

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BTerm

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for BTerm

§

impl RefUnwindSafe for BTerm

§

impl Send for BTerm

§

impl Sync for BTerm

§

impl Unpin for BTerm

§

impl UnwindSafe for BTerm

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
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.