Skip to main content

Frame

Struct Frame 

Source
pub struct Frame { /* private fields */ }
Expand description

A single frame of 3a art, consisting of a grid of cells.

Implementations§

Source§

impl Frame

Source

pub fn to_svg_frame_bg( &self, palette: &Palette, map: &CSSColorMap, font: &Font, ) -> String

Generates SVG background rectangles for colored cells.

Source

pub fn to_svg_frame_txt_fg( &self, palette: &Palette, map: &CSSColorMap, font: &Font, ) -> String

Generates SVG text with foreground colors.

Source

pub fn to_svg_frame_txt(&self, font: &Font) -> String

Generates SVG text without colors.

Source

pub fn to_svg_frame( &self, colors: bool, palette: &Palette, map: &CSSColorMap, font: &Font, ) -> String

Generates SVG for this frame, optionally with colors.

Source

pub fn to_svg( &self, colors: bool, palette: &Palette, map: &CSSColorMap, font: &Font, ) -> String

Generates a complete SVG document for this frame.

Source§

impl Frame

Source

pub fn read_color<R: Read>(lines: &mut Lines<BufReader<R>>) -> Result<Self>

Reads a color-only frame from input lines.

Source

pub fn read_text<R: Read>(lines: &mut Lines<BufReader<R>>) -> Result<Self>

Reads a text-only frame from input lines.

Source

pub fn read_both<R: Read>(lines: &mut Lines<BufReader<R>>) -> Result<Self>

Reads a combined (text+color) frame from input lines.

Source§

impl Frame

Source

pub fn color(&self) -> bool

Returns true if the frame contains any color cells.

Source

pub fn width(&self) -> usize

Returns the width of the frame in cells.

Source

pub fn height(&self) -> usize

Returns the height of the frame in cells.

Source

pub fn remove_color(&mut self, color: Char)

Source

pub fn crop(&mut self, r_from: usize, r_to: usize, c_from: usize, c_to: usize)

Crop frame

Source

pub fn shift_right(&mut self, cols: usize, fill: Cell)

Shifts all rows right by cols, filling new cells with fill.

Source

pub fn shift_left(&mut self, cols: usize, fill: Cell)

Shifts all rows left by cols, filling vacated cells with fill.

Source

pub fn shift_down(&mut self, rows: usize, fill: Cell)

Shifts all columns down by rows, filling new cells with fill.

Source

pub fn shift_up(&mut self, rows: usize, fill: Cell)

Shifts all columns up by rows, filling vacated cells with fill.

Source

pub fn fill_area<C, R>(&mut self, columns: C, rows: R, new: Cell)
where C: IntoIterator<Item = usize>, R: IntoIterator<Item = usize>,

Fills a rectangular area defined by column and row iterators with new cell.

Source

pub fn set(&mut self, column: usize, row: usize, new: Cell)

Sets the cell at (column, row) to new.

Source

pub fn get(&self, column: usize, row: usize, default: Cell) -> Cell

Gets the cell at (column, row), returning default if out of bounds.

Source

pub fn adjust(&mut self, width: usize, height: usize, fill: Cell)

Adjusts frame size to at least width and height, filling new cells with fill.

Source

pub fn adjust_width(&mut self, width: usize, fill: Cell)

Adjusts frame width to at least width.

Source

pub fn adjust_height(&mut self, height: usize, fill: Cell)

Adjusts frame height to at least height.

Source

pub fn resize(&mut self, width: usize, height: usize, fill: Cell)

Resizes frame to exact width and height, filling new cells with fill.

Source

pub fn resize_width(&mut self, width: usize, fill: Cell)

Resizes width to exact width.

Source

pub fn resize_height(&mut self, height: usize, fill: Cell)

Resizes height to exact height.

Source

pub fn contains(&self, cell: Cell) -> bool

Checks if the frame contains the given cell.

Source

pub fn contains_text(&self, ch: Char) -> bool

Checks if the frame contains the given text character.

Source

pub fn contains_color(&self, col: Char) -> bool

Checks if the frame contains the given color character.

Source

pub fn clean(&mut self)

Clears the frame: sets all text to space and color to default.

Source

pub fn fill(&mut self, fill: Cell)

Fills the entire frame with the given cell.

Source

pub fn fill_text(&mut self, fill: Char)

Fills all text cells with the given character.

Source

pub fn fill_color(&mut self, fill: Option<Char>)

Fills all color cells with the given character (or None).

Source

pub fn print( &mut self, col: usize, row: usize, line: &str, color: Option<Option<Char>>, )

Prints text to frame.

Source

pub fn ansi(&self, palette: &Palette, color: bool) -> String

Renders the frame as ANSI escape sequences.

Source

pub fn new(width: usize, height: usize, fill: Cell) -> Self

Creates a new frame of given dimensions filled with fill.

Source

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

Formats the frame’s text channel.

Source

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

Formats the frame’s color channel.

Source

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

Formats both text and color channels concatenated.

Source

pub fn fmt_with_colors( &self, f: &mut Formatter<'_>, colors: Option<bool>, ) -> Result

Formats the frame with optional color inclusion.

Trait Implementations§

Source§

impl Clone for Frame

Source§

fn clone(&self) -> Frame

Returns a duplicate 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 Frame

Source§

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

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

impl Display for Frame

Displays the frame in combined text+color format.

Source§

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

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

impl PartialEq for Frame

Source§

fn eq(&self, other: &Frame) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Frame

Source§

impl StructuralPartialEq for Frame

Auto Trait Implementations§

§

impl Freeze for Frame

§

impl RefUnwindSafe for Frame

§

impl Send for Frame

§

impl Sync for Frame

§

impl Unpin for Frame

§

impl UnsafeUnpin for Frame

§

impl UnwindSafe for Frame

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.