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