diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-01-18 16:49:54 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-01-18 16:49:54 -0500 |
commit | da3bc860f66d34f233028e819beee32dd1c43dd8 (patch) | |
tree | 8cc7f5ad0a8dad69ea5c3ae0405f803d3ba80051 /designer.h | |
parent | 46db0368fbee4cfba97178837e62f4469c4fa884 (diff) | |
download | sap-da3bc860f66d34f233028e819beee32dd1c43dd8.tar.gz sap-da3bc860f66d34f233028e819beee32dd1c43dd8.tar.bz2 sap-da3bc860f66d34f233028e819beee32dd1c43dd8.zip |
Modernized project
This rewrite brings the codebase of this project more in line with the format of the other bots, including things like C++ randomization, better abstraction, use of exceptions, etc. Notably, any FFMPEG objects that get allocated are wrapped in simple objects so that they get properly destroyed if an exception is thrown. Some more error detection and cleanliness stuff can probably be done but my wrists really hurt. Also updated librawr, and thus also removed the yaml-cpp submodule.
Diffstat (limited to 'designer.h')
-rw-r--r-- | designer.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/designer.h b/designer.h new file mode 100644 index 0000000..6a348a0 --- /dev/null +++ b/designer.h | |||
@@ -0,0 +1,40 @@ | |||
1 | #ifndef DESIGNER_H_CCE34BEB | ||
2 | #define DESIGNER_H_CCE34BEB | ||
3 | |||
4 | #include <random> | ||
5 | #include <string> | ||
6 | #include <Magick++.h> | ||
7 | #include <vector> | ||
8 | |||
9 | class designer { | ||
10 | public: | ||
11 | |||
12 | designer(std::string fontsPath); | ||
13 | |||
14 | Magick::Image generate( | ||
15 | size_t width, | ||
16 | size_t height, | ||
17 | const std::string& text, | ||
18 | std::mt19937& rng) const; | ||
19 | |||
20 | private: | ||
21 | |||
22 | const size_t MIN_FONT_SIZE = 48; | ||
23 | const size_t MAX_FONT_SIZE = 96; | ||
24 | const size_t V_PADDING = 5; | ||
25 | const size_t H_PADDING = 5; | ||
26 | |||
27 | size_t maxWordsInLine( | ||
28 | std::vector<std::string>::const_iterator first, | ||
29 | std::vector<std::string>::const_iterator last, | ||
30 | Magick::Image& textimage) const; | ||
31 | |||
32 | size_t minHeightRequired( | ||
33 | std::vector<std::string>::const_iterator first, | ||
34 | std::vector<std::string>::const_iterator last, | ||
35 | Magick::Image& textimage) const; | ||
36 | |||
37 | std::vector<std::string> fonts; | ||
38 | }; | ||
39 | |||
40 | #endif /* end of include guard: DESIGNER_H_CCE34BEB */ | ||