Module coordinates

Module coordinates 

Source
Expand description

Tile and pixel positions and dimensions.

§Coordinate systems

The interface works with two types of coordinates: tile and pixel.

Tile coordinates are given in (row,column) pairs, while pixel coordinates are defined as (x,y) pairs, where $x$ is understood to be the horizontal component and $y$ the vertical component.

Both coordinate systems are left-handed, however they are oriented differently:

  • The tile coordinate origin is taken to be the upper-left, with rows increasing towards the bottom and columns increasing towards the right.
  • The pixel coordinate origin is taken to be the bottom-left, with $x$ increasing towards the right and $y$ increasing towards the top.

The main layout component is the view Canvas component which contains a coordinates field.

§Presentation backends

Different presentation backends may have their own coordinate systems.

Curses

TODO

OpenGL

The OpenGL rendering backend supports both pixel-based and tile-based rendering.

By default the 2D camera is centered with (0,0) in the center of the screen. In the presentation implementation, the camera is moved so that (0,0) is at the bottom-left of the screen.

TODO: more

Re-exports§

pub use self::position::Position;
pub use self::dimensions::Dimensions;

Modules§

dimensions
position

Enums§

Coordinates
Kind

Functions§

pixel_to_tile
Convert a screen pixel (x, y) coordinate to a tile (row, column) coordinate
pixel_to_tile_aabb
Convert a screen pixel (x, y) AABB to tile (row, column) coordinate AABB
tile_to_pixel
Convert a (row, column) coordinate to a screen pixel (x, y) coordinate
tile_to_pixel_aabb
Convert a (row, column) AABB to a screen pixel (x, y) coordinate AABB