From da3bc860f66d34f233028e819beee32dd1c43dd8 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 18 Jan 2018 16:49:54 -0500 Subject: 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. --- designer.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 designer.h (limited to 'designer.h') diff --git a/designer.h b/designer.h new file mode 100644 index 0000000..6a348a0 --- /dev/null +++ b/designer.h @@ -0,0 +1,40 @@ +#ifndef DESIGNER_H_CCE34BEB +#define DESIGNER_H_CCE34BEB + +#include +#include +#include +#include + +class designer { +public: + + designer(std::string fontsPath); + + Magick::Image generate( + size_t width, + size_t height, + const std::string& text, + std::mt19937& rng) const; + +private: + + const size_t MIN_FONT_SIZE = 48; + const size_t MAX_FONT_SIZE = 96; + const size_t V_PADDING = 5; + const size_t H_PADDING = 5; + + size_t maxWordsInLine( + std::vector::const_iterator first, + std::vector::const_iterator last, + Magick::Image& textimage) const; + + size_t minHeightRequired( + std::vector::const_iterator first, + std::vector::const_iterator last, + Magick::Image& textimage) const; + + std::vector fonts; +}; + +#endif /* end of include guard: DESIGNER_H_CCE34BEB */ -- cgit 1.4.1