struct Prism::TextureAtlas
- Prism::TextureAtlas
- Struct
- Value
- Object
Defined in:
prism/texture/texture_atlas.crConstructors
-
.new(size : UInt32)
Produces an atlas for retrieving texture coordinates.
-
.new
Creates an atlas with a default size of 1.
Instance Method Summary
-
#get_coords(col : UInt32, row : UInt32) : TextureCoords
Returns the coordinates for index at the given col and row in the atlas.
-
#get_coords(index : UInt32) : TextureCoords
Returns the coordinates for an index in the atlas.
- #size : UInt32
Constructor Detail
Produces an atlas for retrieving texture coordinates.
The size determins the number of columns and rows in the atlas.
Example
A size of 4 will produces a 4x4 atlas. Coordinates for each texture in the atlas will be retrievable by the index number.
+---------------+ | 0 | 1 | 2 | 3 | |---|---|---|---| | 4 | 5 | 6 | 7 | |---|---|---|---| | 8 | 9 | 10| 11| |---|---|---|---| | 12| 13| 14| 15| +---------------+
Creates an atlas with a default size of 1. This will produces coordinates for a regular texture that is not an atlas.
Instance Method Detail
Returns the coordinates for index at the given col and row in the atlas.
Returns the coordinates for an index in the atlas.
Example
Given a 4x4 grid like this one:
+---------------+ | 0 | 1 | 2 | 3 | |---|---|---|---| | 4 | 5 | 6 | 7 | |---|---|---|---| | 8 | 9 | 10| 11| |---|---|---|---| | 12| 13| 14| 15| +---------------+
We can fetch the coordinates at index 9:
texture_atlas.get_coordinates(9) # => { col: 1, row: 2}