Skip to main content

SpriteSkin

Struct SpriteSkin 

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

A grid map’s ground painted from terrain tiles.

Implementations§

Source§

impl SpriteSkin

Source

pub const fn new( terrain: Option<TerrainTiles>, glyph: GlyphSkin, walk: WalkSpeeds, ) -> Self

The skin of terrain at the art’s own size, with glyph’s colors (and its ground, without terrain tiles), showing a walk at walk.

Source

pub fn with_zooms(self, levels: &[i32]) -> Self

The same skin, offering levels as its zoom_levels when its terrain tiles paint the ground: sorted, each once, those below 1 left out.

Source

pub fn zoomed(self, zoom: i32) -> Self

The same skin drawn zoom times the art’s size (at least once).

Source

pub const fn terrain(&self) -> Option<&TerrainTiles>

Its terrain tiles, if it has them.

Source

pub const fn zoom(&self) -> i32

The zoom it was given: console pixels per pixel of the art, when it has terrain tiles.

Source

pub fn tile_size(&self) -> (i32, i32)

A map tile’s size on screen, across × down, in console pixels: the tiles’ times the zoom, or the glyph skin’s without terrain tiles. Everything that depends on the tile size goes through this.

Source

pub fn view_tiles(&self, area: Rect) -> (i32, i32)

The area’s pixels divided by the tile size, rounded down; without terrain tiles, what the glyph skin fits.

Source

pub fn grid<U>(&self, scene: &MapScene<U>, area: Rect) -> Grid

Where scene’s tiles go in area: as many as fit, the pixels left over split evenly around them; without terrain tiles, where the glyph skin puts them.

Trait Implementations§

Source§

impl Clone for SpriteSkin

Source§

fn clone(&self) -> SpriteSkin

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SpriteSkin

Source§

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

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

impl<U> GridSkin<U> for SpriteSkin

Source§

fn name(&self) -> &'static str

"sprite" when the tiles paint the ground, "sprite_units" on the glyph skin’s ground.

Source§

fn zoom_levels(&self) -> &[i32]

The levels it was given (SpriteSkin::with_zooms), with terrain tiles; none without.

Source§

fn paint( &self, looks: &Looks<'_>, scene: &MapScene<U>, area: Rect, units: &dyn UnitPainter<U>, buf: &mut GlyphBuffer, )

The ground (terrain tinted by flashes and ranges), what lies under the units (UnitPainter::paint_under), the path’s line, the units, the path’s arrowhead, what lies over them (UnitPainter::paint_over), then the cursor; over them all, the threat arrows and marks.

Source§

fn tile_size(&self) -> (i32, i32)

A map tile’s size on screen, across × down, in console pixels.
Source§

fn view_tiles(&self, area: Rect) -> (i32, i32)

How many tiles, across × down, fit in a map area of area cells.
Source§

fn grid(&self, scene: &MapScene<U>, area: Rect) -> Grid

Where scene’s tiles go when it is painted into area.
Source§

fn walk(&self) -> WalkSpeeds

How fast a unit’s walk is shown under this skin.
Source§

fn zoom(&self) -> Option<i32>

The zoom it draws at, or None if it can’t zoom.
Source§

fn at_zoom(&self, zoom: i32) -> Option<Rc<dyn GridSkin<U>>>

The same skin drawing at zoom, or None if zoom isn’t one of its zoom_levels.
Source§

fn tile_px(&self, scene: &MapScene<U>, area: Rect, tile: Pos) -> Option<PxRect>

The console pixels of tile when scene is painted into area, or None if it isn’t visible. Menus and popups go beside it.
Source§

fn tile_cells(&self, scene: &MapScene<U>, area: Rect, tile: Pos) -> Option<Rect>

The cells tile_px touches.
Source§

impl PartialEq for SpriteSkin

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SpriteSkin

Auto Trait Implementations§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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.