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(
unsigned int y = 0; y < numberOfRows; y++)
42 for(
unsigned 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 (
unsigned int y = 0; y < numberOfRows; y++)
87 for (
unsigned 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;
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;
169 unsigned int cellWidth;
170 unsigned int cellHeight;
173 const std::size_t cellsNum = fontAtlas.size();
175 const double totalSquare =
176 static_cast<double>(cellWidth) *
177 static_cast<double>(cellHeight) *
178 static_cast<double>(cellsNum);
180 const double rootSq = std::sqrt(totalSquare);
182 outputNumberOfColumns =
static_cast<unsigned int>(
183 std::ceil(rootSq /
static_cast<double>(cellWidth)));
185 outputNumberOfRows =
static_cast<unsigned int>(
187 static_cast<double>(cellsNum) /
188 static_cast<double>(outputNumberOfColumns)));
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 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.