diff --git a/.gitignore b/.gitignore index e929830..8bd652d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.zip packing +build.sh diff --git a/README.md b/README.md index 94a84f0..233682d 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,24 @@ The subject is available here: [Test Algo](./test_algo.pdf) ### Question 1 ### Question 2 ### Question 3 + +## PNG support + +I chose to support PNG files through the stb files: +[github.com/nothings/stb](https://github.com/nothings/stb). +I could have implemented basic image support with the PNM format but I think it +is nicer to support common image formats with a simple library. + +stb also implements a 2D rectangle packer: +[stb_rect_pack.h](https://github.com/nothings/stb/blob/master/stb_rect_pack.h) +I added this file in the project in order to compare my implementation to +another one. + +## 3rd party libraries + +I use 2 external libraries for better visualization: +- stb files (for PNG) +- raylib (for GUI) + +I don't rely on them for the algorithm implementation and the core of the +exercise doesn't rely on external libraries. diff --git a/justfile b/justfile index 02765a0..ca30572 100644 --- a/justfile +++ b/justfile @@ -9,6 +9,8 @@ run: build {{exe}} generate-build: + git clean -xf src/ + rm --force {{exe}} tup generate {{build_sh}} debug: build diff --git a/src/main_cli.cpp b/src/main_cli.cpp new file mode 100644 index 0000000..398558b --- /dev/null +++ b/src/main_cli.cpp @@ -0,0 +1,24 @@ +#include +#include + +namespace fs = std::filesystem; + +int main(int argc, const char* argv[]) { + // We take an image path and a list of points (grouped by 4 to define + // bounding boxes). + if (argc < 6 or (argc - 2) % 4 != 0) { + std::cerr + << "Usage: " << argv[0] << " path/to/image" + << " x1 y1 x2 y2 [...]\n" + << "x/y points must be grouped by 4 to define bounding boxes\n"; + return 1; + } + + const fs::path input(argv[1]); + if (!fs::exists(input)) { + std::cerr << "Input file " << input << " does not exist.\n"; + return 1; + } + + return 0; +}