Loading...
Searching...
No Matches
ml::ImageRects Class Reference

A grid-indexed collection of sf::IntRect regions. More...

#include <ImageRects.h>

Public Member Functions

 ImageRects (int cols)
 Construct an empty ImageRects with a known column count.
const sf::IntRectgetIntRect (int row, int col)
 Return the rect for a given row and column.
void push (const sf::IntRect &int_rect)
 Append a rect to the collection.

Detailed Description

A grid-indexed collection of sf::IntRect regions.

ImageRects stores the sub-rectangle regions produced by TextureSlicer::getImageRects when a texture is divided into a uniform grid of rows and columns. Each rect describes the pixel bounds of one cell within the source texture, ready to be passed to sf::Sprite::setTextureRect for sprite-sheet animation or tile-based rendering.

Rects are stored in row-major order and accessed by (row, col) index.

Usage

// Access frame (row 1, col 3)
sprite.setTextureRect(rects.getIntRect(1, 3));
A grid-indexed collection of sf::IntRect regions.
Definition ImageRects.h:37
const sf::IntRect & getIntRect(int row, int col)
Return the rect for a given row and column.
static ml::ImageRects getImageRects(const sf::Texture &texture, int rows, int cols)
Slice a texture into a rows × cols grid of equal rectangles.
See also
TextureSlicer

Definition at line 36 of file ImageRects.h.

Constructor & Destructor Documentation

◆ ImageRects()

ml::ImageRects::ImageRects ( int cols)

Construct an empty ImageRects with a known column count.

Parameters
colsNumber of columns in the source grid. Used to convert (row, col) indices to a flat vector position.

Member Function Documentation

◆ getIntRect()

const sf::IntRect & ml::ImageRects::getIntRect ( int row,
int col )

Return the rect for a given row and column.

Parameters
rowZero-based row index.
colZero-based column index.
Returns
Const reference to the sf::IntRect for that cell.

◆ push()

void ml::ImageRects::push ( const sf::IntRect & int_rect)

Append a rect to the collection.

Called by TextureSlicer to populate the collection in row-major order. Direct use is uncommon outside of framework internals.

Parameters
int_rectThe rect to append.

The documentation for this class was generated from the following file: