gl_utils/
tile.rs

1//! Tile utilities.
2//!
3//! # Coordinates
4//!
5//! Tile space coordinates are defined as left-handed^* (row,column) coordinates
6//! with the origin in the upper-left corner of the current viewport. Because
7//! the origin in 2D world coordinates is relative to the current viewport, it
8//! will change depending on the current viewport dimensions.
9//!
10//! ^*: "left-handed" in the sense of taking the left hand with palm facing down
11//! (away) and taking the thumb to be the first coordinate and index finger to
12//! be the second coordinate
13//!
14//! The tile space vertex shader stages take as input a tile (row,column) and
15//! output the 2D world space coordinate for the upper-left corner of the tile.
16//! The tile geometry shader will then produce the remaining vertices from this
17//! coordinate.
18
19use crate::vertex;
20
21/// Create tile vertices from a string of characters at a given (row,col)
22/// position
23pub fn vertices (string : &str, (row, col) : (i32, i32))
24  -> Vec <vertex::Vert2dTile>
25{
26  string.chars().enumerate().map (
27    |(i,ch)| vertex::Vert2dTile { row, column: col + i as i32, tile: ch as u8 }
28  ).collect()
29}