From 460b99583bcf6da4462f13ad75856283849904e7 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 4 Nov 2024 02:37:02 -0500 Subject: main.cpp does work for standalone entry --- main.cpp | 16 ++++++++++------ wizard.cpp | 17 +++++++---------- wizard.h | 18 ++++++++++-------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/main.cpp b/main.cpp index a0ba7bb..9327c20 100644 --- a/main.cpp +++ b/main.cpp @@ -4,6 +4,8 @@ #include #include +#include "cardset.h" +#include "imagestore.h" #include "wizard.h" int main(int argc, char** argv) { @@ -29,16 +31,18 @@ int main(int argc, char** argv) { "o", "output", "Path to write image output to", true, "", "filename"); cmd.add(outputPath); - TCLAP::ValueArg jsonPath( - "j", "json", "Path to write JSON output to", false, "", "filename"); - cmd.add(jsonPath); + TCLAP::ValueArg textInput("t", "text", "Text to render", true, + "", "text"); + cmd.add(textInput); cmd.parse(argc, argv); - wizard app(cardsPath.getValue(), cachePath.getValue(), - outputPath.getValue(), jsonPath.getValue(), rng); + cardset cards(cardsPath.getValue()); + imagestore images(cachePath.getValue()); - app.run(); + wizard app(cards, images, textInput.getValue(), rng); + Magick::Image result = app.run(); + result.write(outputPath.getValue()); } catch (const TCLAP::ArgException& e) { std::cerr << "Error: " << e.error() << " for arg " << e.argId() << std::endl; diff --git a/wizard.cpp b/wizard.cpp index 4eaefb3..1541fed 100644 --- a/wizard.cpp +++ b/wizard.cpp @@ -38,13 +38,9 @@ class pix_deleter { using pix_ptr = std::unique_ptr; -wizard::wizard(std::string cardsPath, std::string cachePath, - std::string outputPath, std::string jsonPath, std::mt19937& rng) - : cards_(cardsPath), - images_(cachePath), - outputPath_(outputPath), - jsonPath_(jsonPath), - rng_(rng) { +wizard::wizard(const cardset& cards, const imagestore& images, std::string text, + std::mt19937& rng) + : cards_(cards), images_(images), text_(text), rng_(rng()) { std::cout << "Characters: "; for (char ch : cards_.getCharacters()) { @@ -54,8 +50,8 @@ wizard::wizard(std::string cardsPath, std::string cachePath, std::cout << std::endl; } -void wizard::run() { - std::string text = "what the heck, it's just some gay guy"; +Magick::Image wizard::run() { + std::string text = text_; //"what the heck, it's just some gay guy"; // getline(std::cin, text); if (text.back() == '\r') { text.pop_back(); @@ -252,5 +248,6 @@ void wizard::run() { } endImage.magick("PNG"); - endImage.write(outputPath_); + + return endImage; } diff --git a/wizard.h b/wizard.h index 9b27143..a02197b 100644 --- a/wizard.h +++ b/wizard.h @@ -1,6 +1,8 @@ #ifndef WIZARD_H_1014B13E #define WIZARD_H_1014B13E +#include + #include #include @@ -9,17 +11,17 @@ class wizard { public: - wizard(std::string cardsPath, std::string cachePath, std::string outputPath, - std::string jsonPath, std::mt19937& rng); + wizard(const cardset& cards, const imagestore& images, std::string text, + std::mt19937& rng); - void run(); + Magick::Image run(); private: - cardset cards_; - imagestore images_; - std::string outputPath_; - std::string jsonPath_; - std::mt19937& rng_; + const cardset& cards_; + const imagestore& images_; + std::string text_; + + std::mt19937 rng_; }; #endif /* end of include guard: WIZARD_H_1014B13E */ -- cgit 1.4.1