25 unsigned int cellWidth;
26 unsigned int cellHeight;
30 unsigned int numberOfColumns;
31 unsigned int numberOfRows;
35 ImageData textureAtlasPalette(
static_cast<unsigned int>(cellWidth * numberOfColumns),
static_cast<unsigned int>(cellHeight * numberOfRows));
40 for(
int y = 0; y < numberOfRows; y++ )
42 for(
int x = 0; x < numberOfColumns; x++ )
48 texAtlasData.emplace(imageIterator->first, std::make_pair<unsigned int, unsigned int>(x * cellWidth, y * cellHeight));
55 texAtlasImage = textureAtlasPalette;
62 if (ioFontAtlas.size() == 0)
70 unsigned int cellWidth;
71 unsigned int cellHeight;
75 unsigned int numberOfColumns;
76 unsigned int numberOfRows;
80 ImageData textureAtlasPalette(
static_cast<unsigned int>(cellWidth * numberOfColumns),
static_cast<unsigned int>(cellHeight * numberOfRows));
83 auto imageIterator = ioFontAtlas.begin();
85 for (
int y = 0; y < numberOfRows; y++)
87 for (
int x = 0; x < numberOfColumns; x++)
89 if (imageIterator != ioFontAtlas.end())
93 imageIterator->second.first.atlasX =
static_cast<std::uint32_t
>(x * cellWidth) + imageIterator->second.first.padding;
94 imageIterator->second.first.atlasY =
static_cast<std::uint32_t
>(y * cellHeight) + imageIterator->second.first.padding;
101 return textureAtlasPalette;
106 unsigned int height = 0U;
107 unsigned int width = 0U;
110 if( it.second.GetHeight() >= height )
112 height = it.second.GetHeight();
114 if( it.second.GetWidth() >= width )
116 width = it.second.GetWidth();
121 outputHeight = height;
126 unsigned int height = 0U;
127 unsigned int width = 0U;
128 for (
auto& it : fontAtlas)
130 if (it.second.second.GetHeight() >= height)
132 height = it.second.second.GetHeight();
134 if (it.second.second.GetWidth() >= width)
136 width = it.second.second.GetWidth();
141 outputHeight = height;
146 unsigned int cellWidth;
147 unsigned int cellHeight;
151 int totalSquare = cellWidth * cellHeight * cellsNum;
152 float rootSq = sqrtf(totalSquare);
154 outputNumberOfColumns = std::ceil(rootSq / cellWidth);
155 outputNumberOfRows = std::ceil((
float)(cellsNum) / (
float)(outputNumberOfColumns));
160 unsigned int cellWidth;
161 unsigned int cellHeight;
164 unsigned int cellsNum = fontAtlas.size();
165 int totalSquare = cellWidth * cellHeight * cellsNum;
166 float rootSq = sqrtf(totalSquare);
168 outputNumberOfColumns = std::ceil(rootSq / cellWidth);
169 outputNumberOfRows = std::ceil((
float)(cellsNum) / (
float)(outputNumberOfColumns));
Represents raw 2D image data stored in memory.
static void DrawImageOnImageAtPos(unsigned int const x, unsigned int const y, ImageData &toImage, ImageData &fromImage)
Overlays one image on top of another at a given position.
void Fill(Color color)
Fills the image with a solid color.
void FindCellDimensions(unsigned int &outputWidth, unsigned int &outputHeight)
Computes maximum cell dimensions for the stored images.
bool CreateTextureAtlas(std::map< char, std::pair< unsigned int, unsigned int > > &texAtlasData, ImageData &texAtlasImage)
Creates a texture atlas from the stored image collection.
TextureAtlasMaker(std::map< char, ImageData > images)
Constructs an atlas maker from a collection of images.
std::map< char, ImageData > mImageCollection
static const Color sDefaultPaletteBackgroundColor
void CalculateGridDimensions(unsigned int &outputNumberOfColumns, unsigned int &outputNumberOfRows)
Calculates grid dimensions for the stored images.