diff options
Diffstat (limited to 'infinite.cpp')
| -rw-r--r-- | infinite.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
| diff --git a/infinite.cpp b/infinite.cpp index a491302..1409ba2 100644 --- a/infinite.cpp +++ b/infinite.cpp | |||
| @@ -439,7 +439,15 @@ int main(int argc, char** argv) | |||
| 439 | 439 | ||
| 440 | Magick::InitializeMagick(nullptr); | 440 | Magick::InitializeMagick(nullptr); |
| 441 | 441 | ||
| 442 | YAML::Node config = YAML::LoadFile("config.yml"); | 442 | if (argc != 2) |
| 443 | { | ||
| 444 | std::cout << "usage: infinite [configfile]" << std::endl; | ||
| 445 | return -1; | ||
| 446 | } | ||
| 447 | |||
| 448 | std::string configfile(argv[1]); | ||
| 449 | YAML::Node config = YAML::LoadFile(configfile); | ||
| 450 | |||
| 443 | twitter::auth auth; | 451 | twitter::auth auth; |
| 444 | auth.setConsumerKey(config["consumer_key"].as<std::string>()); | 452 | auth.setConsumerKey(config["consumer_key"].as<std::string>()); |
| 445 | auth.setConsumerSecret(config["consumer_secret"].as<std::string>()); | 453 | auth.setConsumerSecret(config["consumer_secret"].as<std::string>()); |
| @@ -451,10 +459,10 @@ int main(int argc, char** argv) | |||
| 451 | // Parse forms file | 459 | // Parse forms file |
| 452 | std::map<std::string, std::vector<std::string>> groups; | 460 | std::map<std::string, std::vector<std::string>> groups; |
| 453 | { | 461 | { |
| 454 | std::ifstream datafile("forms.txt"); | 462 | std::ifstream datafile(config["forms_file"].as<std::string>()); |
| 455 | if (!datafile.is_open()) | 463 | if (!datafile.is_open()) |
| 456 | { | 464 | { |
| 457 | std::cout << "Could not find forms.txt" << std::endl; | 465 | std::cout << "Could not find forms file" << std::endl; |
| 458 | return 1; | 466 | return 1; |
| 459 | } | 467 | } |
| 460 | 468 | ||
| @@ -484,11 +492,12 @@ int main(int argc, char** argv) | |||
| 484 | } | 492 | } |
| 485 | 493 | ||
| 486 | // Read in fonts | 494 | // Read in fonts |
| 495 | std::string fontsdirname = config["fonts"].as<std::string>(); | ||
| 487 | std::vector<std::string> fonts; | 496 | std::vector<std::string> fonts; |
| 488 | { | 497 | { |
| 489 | DIR* fontdir; | 498 | DIR* fontdir; |
| 490 | struct dirent* ent; | 499 | struct dirent* ent; |
| 491 | if ((fontdir = opendir("fonts")) == nullptr) | 500 | if ((fontdir = opendir(fontsdirname.c_str())) == nullptr) |
| 492 | { | 501 | { |
| 493 | std::cout << "Couldn't find fonts." << std::endl; | 502 | std::cout << "Couldn't find fonts." << std::endl; |
| 494 | return -1; | 503 | return -1; |
| @@ -506,7 +515,9 @@ int main(int argc, char** argv) | |||
| 506 | closedir(fontdir); | 515 | closedir(fontdir); |
| 507 | } | 516 | } |
| 508 | 517 | ||
| 509 | verbly::data database {"data.sqlite3"}; | 518 | std::string colorsfile(config["colors"].as<std::string>()); |
| 519 | |||
| 520 | verbly::data database {config["verbly_datafile"].as<std::string>()}; | ||
| 510 | 521 | ||
| 511 | for (;;) | 522 | for (;;) |
| 512 | { | 523 | { |
| @@ -614,7 +625,7 @@ int main(int argc, char** argv) | |||
| 614 | { | 625 | { |
| 615 | std::cout << "Generating flame fractal..." << std::endl; | 626 | std::cout << "Generating flame fractal..." << std::endl; |
| 616 | 627 | ||
| 617 | Fractal fractal = Fractal::random(); | 628 | Fractal fractal = Fractal::random(colorsfile); |
| 618 | std::vector<Color> irradiance(target_w*target_h*sample_rate*sample_rate, Color(0.0, 0.0, 0.0, 0.0)); | 629 | std::vector<Color> irradiance(target_w*target_h*sample_rate*sample_rate, Color(0.0, 0.0, 0.0, 0.0)); |
| 619 | 630 | ||
| 620 | double x = (double)rand()/(double)RAND_MAX*2.0-1.0; | 631 | double x = (double)rand()/(double)RAND_MAX*2.0-1.0; |
| @@ -730,7 +741,7 @@ int main(int argc, char** argv) | |||
| 730 | // Put text on top of the fractal | 741 | // Put text on top of the fractal |
| 731 | std::string subaction = action; | 742 | std::string subaction = action; |
| 732 | std::string font = fonts[rand() % fonts.size()]; | 743 | std::string font = fonts[rand() % fonts.size()]; |
| 733 | if (font == "Le_Super_Type_SemiBold.ttf") | 744 | if (font.find("Le_Super_Type_SemiBold.ttf") != std::string::npos) |
| 734 | { | 745 | { |
| 735 | std::transform(std::begin(subaction), std::end(subaction), std::begin(subaction), [] (char ch) { | 746 | std::transform(std::begin(subaction), std::end(subaction), std::begin(subaction), [] (char ch) { |
| 736 | return std::toupper(ch); | 747 | return std::toupper(ch); |
| @@ -741,7 +752,7 @@ int main(int argc, char** argv) | |||
| 741 | textimage.type(Magick::TrueColorMatteType); | 752 | textimage.type(Magick::TrueColorMatteType); |
| 742 | textimage.fillColor(Magick::Color("white")); | 753 | textimage.fillColor(Magick::Color("white")); |
| 743 | textimage.fontPointsize(72.0); | 754 | textimage.fontPointsize(72.0); |
| 744 | textimage.font("fonts/" + font); | 755 | textimage.font(fontsdirname + "/" + font); |
| 745 | 756 | ||
| 746 | auto words = verbly::split<std::list<std::string>>(subaction, " "); | 757 | auto words = verbly::split<std::list<std::string>>(subaction, " "); |
| 747 | std::string towrite = ""; | 758 | std::string towrite = ""; |
