pub trait GridSkin<U>: Debug {
// Required methods
fn name(&self) -> &'static str;
fn tile_size(&self) -> (i32, i32);
fn view_tiles(&self, area: Rect) -> (i32, i32);
fn grid(&self, scene: &MapScene<U>, area: Rect) -> Grid;
fn walk(&self) -> WalkSpeeds;
fn paint(
&self,
looks: &Looks<'_>,
scene: &MapScene<U>,
area: Rect,
units: &dyn UnitPainter<U>,
buf: &mut GlyphBuffer,
);
// Provided methods
fn zoom_levels(&self) -> &[i32] { ... }
fn zoom(&self) -> Option<i32> { ... }
fn at_zoom(&self, _zoom: i32) -> Option<Rc<dyn GridSkin<U>>> { ... }
fn tile_px(
&self,
scene: &MapScene<U>,
area: Rect,
tile: Pos,
) -> Option<PxRect> { ... }
fn tile_cells(
&self,
scene: &MapScene<U>,
area: Rect,
tile: Pos,
) -> Option<Rect> { ... }
}Expand description
Paints grid maps of units U. The tile size is the skin’s: screens ask
it how many tiles fit and where a tile is. A skin never changes the
game: only the frame, how many tiles are on screen, and how fast a
walk is shown.
Required Methods§
Sourcefn tile_size(&self) -> (i32, i32)
fn tile_size(&self) -> (i32, i32)
A map tile’s size on screen, across × down, in console pixels.
Sourcefn view_tiles(&self, area: Rect) -> (i32, i32)
fn view_tiles(&self, area: Rect) -> (i32, i32)
How many tiles, across × down, fit in a map area of area cells.
Sourcefn grid(&self, scene: &MapScene<U>, area: Rect) -> Grid
fn grid(&self, scene: &MapScene<U>, area: Rect) -> Grid
Where scene’s tiles go when it is painted into area.
Sourcefn walk(&self) -> WalkSpeeds
fn walk(&self) -> WalkSpeeds
How fast a unit’s walk is shown under this skin.
Sourcefn paint(
&self,
looks: &Looks<'_>,
scene: &MapScene<U>,
area: Rect,
units: &dyn UnitPainter<U>,
buf: &mut GlyphBuffer,
)
fn paint( &self, looks: &Looks<'_>, scene: &MapScene<U>, area: Rect, units: &dyn UnitPainter<U>, buf: &mut GlyphBuffer, )
Paints scene into the cells of area, its units by units: a
painter the caller may build each frame, from what that frame paints
with (see the module’s docs). Touches nothing outside it.
Provided Methods§
Sourcefn zoom_levels(&self) -> &[i32]
fn zoom_levels(&self) -> &[i32]
The zooms it can draw the map at, smallest first: console pixels per pixel of its art. None if it can’t zoom (the glyph skin: its tile is two font cells).
Sourcefn at_zoom(&self, _zoom: i32) -> Option<Rc<dyn GridSkin<U>>>
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".