Divides a texture into a uniform grid of sub-rectangles. More...
#include <TextureSlicer.h>
Static Public Member Functions | |
| static ml::ImageRects | getImageRects (const sf::Texture &texture, int rows, int cols) |
| Slice a texture into a rows × cols grid of equal rectangles. | |
Divides a texture into a uniform grid of sub-rectangles.
TextureSlicer calculates the pixel bounds of each cell when a texture is divided into rows rows and cols columns of equal size, returning the results as an ImageRects collection.
This is the primary utility for working with sprite sheets and tile atlases — slice once, then use the resulting rects with sf::Sprite::setTextureRect to display individual frames or tiles.
Definition at line 38 of file TextureSlicer.h.
|
static |
Slice a texture into a rows × cols grid of equal rectangles.
Divides the texture's pixel dimensions evenly, computing one sf::IntRect per cell in row-major order. The rects are stored in the returned ImageRects object.
| texture | The source texture to slice. Must be fully loaded. |
| rows | Number of rows to divide the texture into. |
| cols | Number of columns to divide the texture into. |
ImageRects containing rows × cols rects, accessible by (row, col) index.