Skip to main content

Grid

Struct Grid 

Source
pub struct Grid {
    pub origin: Pos,
    pub corner: (i32, i32),
    pub tile: (i32, i32),
    pub tiles: (i32, i32),
    pub scale: i32,
    pub projection: Projection,
}
Expand description

The tiles of a scene laid out on the console.

Fields§

§origin: Pos

The map tile in the top-left corner.

§corner: (i32, i32)

The top-left pixel of that tile.

§tile: (i32, i32)

A tile’s size in pixels, across × down.

§tiles: (i32, i32)

Tiles drawn, across × down.

§scale: i32

Console pixels per pixel of the art (the skin’s zoom): 1 unless everything on the map is drawn bigger. tile already counts it.

§projection: Projection

How the tiles are laid.

Implementations§

Source§

impl Grid

Source

pub const fn top_down( origin: Pos, corner: (i32, i32), tile: (i32, i32), tiles: (i32, i32), scale: i32, ) -> Self

tiles tiles of tile pixels from the map tile origin, whose top-left pixel is corner, laid top-down at the zoom scale.

Source

pub fn offset(&self, tile: Pos) -> Option<(i32, i32)>

Where tile is, as tiles right of and below the origin, if drawn.

Source

pub fn tile_px(&self, tile: Pos) -> (i32, i32)

The top-left pixel of tile, drawn or not (it may lie outside the grid).

Source

pub fn rect_at(&self, dx: i32, dy: i32) -> PxRect

The pixels of the tile dx right of and dy below the origin.

Source

pub fn rect(&self, tile: Pos) -> Option<PxRect>

The pixels of tile, or None if it isn’t drawn.

Source

pub fn zoom(&self) -> i32

The skin’s zoom, at least 1.

Source

pub fn art_tile(&self) -> PxRect

A tile at the art’s own size, its corner at (0, 0): what a mark’s place on a tile is worked out on, whatever the zoom (zoomed).

Source

pub fn at_art_size(&self) -> Self

The same tiles at the art’s own size, laid from (0, 0): what a drawing across tiles (the path) is worked out on, whatever the zoom, before zoomed from this grid’s corner places it.

Source

pub fn zoomed(&self, corner: (i32, i32), art: PxRect) -> PxRect

art, pixels worked out on art_tile, on the tile whose top-left pixel is corner: every art pixel a square of the zoom’s console pixels.

Source

pub fn bounds(&self) -> PxRect

The pixels every drawn tile covers.

Trait Implementations§

Source§

impl Clone for Grid

Source§

fn clone(&self) -> Grid

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 Copy for Grid

Source§

impl Debug for Grid

Source§

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

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

impl Eq for Grid

Source§

impl PartialEq for Grid

Source§

fn eq(&self, other: &Grid) -> 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 Grid

Auto Trait Implementations§

§

impl Freeze for Grid

§

impl RefUnwindSafe for Grid

§

impl Send for Grid

§

impl Sync for Grid

§

impl Unpin for Grid

§

impl UnsafeUnpin for Grid

§

impl UnwindSafe for Grid

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.