#include <exception>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <ranges>
#include <vector>
#include "../lodepng/lodepng.h"
Go to the source code of this file.
|
| std::vector< std::string > | readDirectory (std::string path, std::string extension) |
| | Reads all the files in the directory and returns a vector of the filenames. Only returns files with the given extension. More...
|
| |
| void | readPng (std::vector< unsigned char > &image, unsigned &width, unsigned &height, std::string filepath) |
| | Reads a PNG file and returns the image data, width and height. More...
|
| |
| template<typename T > |
| void | rotateMatrix (std::vector< std::vector< T >> &matrix, uint8_t rotation) |
| | Rotates the matrix 90 degrees counter-clockwise. Rotation is calculated by rotation-param * 90 degrees. More...
|
| |
| template<typename T > |
| void | populateMatrix (std::vector< std::vector< T >> &matrix, const std::vector< std::vector< std::string >> &areaMap, T defaultValue, unsigned AREA_WIDTH, unsigned AREA_HEIGHT) |
| | Populates a matrix with a default value. The matrix is all the areas combined and expanded e.g. the whole map. The matrix row sizes DO NOT need to match. More...
|
| |
| template<typename T , typename K > |
| void | populateMatrixFromReference (std::vector< std::vector< T >> &matrix, const std::vector< std::vector< K >> &referenceMatrix, T defaultValue) |
| | Populates a matrix from a reference matrix. Uses a default value for empty cells. Reference matrix is given (instead of it's dimensions) because the row sizes might not match. More...
|
| |
| template<typename T > |
| void | writeMatrixToFile (const std::vector< std::vector< T >> &matrix, const std::string &filepath) |
| | Takes in a matrix<T> and writes that to a text file. Values are separated by commas and rows by newlines. More...
|
| |
◆ populateMatrix()
template<typename T >
| void populateMatrix |
( |
std::vector< std::vector< T >> & |
matrix, |
|
|
const std::vector< std::vector< std::string >> & |
areaMap, |
|
|
T |
defaultValue, |
|
|
unsigned |
AREA_WIDTH, |
|
|
unsigned |
AREA_HEIGHT |
|
) |
| |
Populates a matrix with a default value. The matrix is all the areas combined and expanded e.g. the whole map. The matrix row sizes DO NOT need to match.
- Parameters
-
| matrix | |
| areaMap | |
| defaultValue | |
| AREA_WIDTH | |
| AREA_HEIGHT | |
◆ populateMatrixFromReference()
template<typename T , typename K >
| void populateMatrixFromReference |
( |
std::vector< std::vector< T >> & |
matrix, |
|
|
const std::vector< std::vector< K >> & |
referenceMatrix, |
|
|
T |
defaultValue |
|
) |
| |
Populates a matrix from a reference matrix. Uses a default value for empty cells. Reference matrix is given (instead of it's dimensions) because the row sizes might not match.
- Parameters
-
| matrix | |
| referenceMatrix | |
| defaultValue | to fill the matrix with |
◆ readDirectory()
| std::vector<std::string> readDirectory |
( |
std::string |
path, |
|
|
std::string |
extension |
|
) |
| |
Reads all the files in the directory and returns a vector of the filenames. Only returns files with the given extension.
- Parameters
-
| path | Path to the directory |
| extension | File extension to filter the files |
- Returns
- std::vector<std::string> Vector of filenames
◆ readPng()
| void readPng |
( |
std::vector< unsigned char > & |
image, |
|
|
unsigned & |
width, |
|
|
unsigned & |
height, |
|
|
std::string |
filepath |
|
) |
| |
Reads a PNG file and returns the image data, width and height.
- Parameters
-
| image | Vector to store the image data |
| width | Width of the image |
| height | Height of the image |
| filepath | Filepath to the PNG file |
◆ rotateMatrix()
template<typename T >
| void rotateMatrix |
( |
std::vector< std::vector< T >> & |
matrix, |
|
|
uint8_t |
rotation |
|
) |
| |
Rotates the matrix 90 degrees counter-clockwise. Rotation is calculated by rotation-param * 90 degrees.
- Parameters
-
| matrix | Matrix to rotate |
| rotation | Number of 90 degree rotations |
◆ writeMatrixToFile()
template<typename T >
| void writeMatrixToFile |
( |
const std::vector< std::vector< T >> & |
matrix, |
|
|
const std::string & |
filepath |
|
) |
| |
Takes in a matrix<T> and writes that to a text file. Values are separated by commas and rows by newlines.
Row sizes do not need to match.
- Parameters
-
| matrix | Matrix to write to file |
| filepath | Filepath to write to |