Пример #1
0
int main(int argc, char const *argv[]) throw()
{
  Beta::Cfg beta_cfg;
  Delta::Cfg delta_cfg;
  int opt_seven = 7777777;

  CommandlineOptions opts;
  opts.add_help("Test application for the command-line interpreter "
                "of the archon::Core library.\n"
                "By Kristian Spangsege.", "  WIDTH  HEIGHT  ");
  opts.check_num_args(0,-1);
  opts.add_version("5.5");
  opts.add_stop_opts();
  opts.handle_config_file("/tmp/archon-core-test-options.conf");
  opts.add_group(beta_cfg, "beta");
  opts.add_group(delta_cfg, "delta");
  opts.add_param("7", "seven", opt_seven, "The Seventh Seal");

/*
  char const *argv[] = { "/tuba/rilo", "-l", "7", "" };
  int argc = sizeof(argv)/sizeof(argv[0]);
*/
  if(int stop = opts.process(argc, argv)) return stop == 2 ? 0 : 1;

  cerr << "argc = " << argc << endl;

  return 0;
}
Пример #2
0
int main(int argc, const char* argv[])
{
    std::set_terminate(&cxx::terminate_handler);
    try_fix_preinstall_datadir(argv[0], "render/test/");

    Application::Config cfg;
    CommandlineOptions opts;
    opts.add_help("Test application for the scene builder feature");
    opts.check_num_args();
    opts.add_group(cfg);
    if (int stop = opts.process(argc, argv))
        return stop == 2 ? EXIT_SUCCESS : EXIT_FAILURE;
    SceneBuilderApp(cfg).run();
}
Пример #3
0
int main(int argc, const char* argv[])
{
    std::set_terminate(&cxx::terminate_handler);
    try_fix_preinstall_datadir(argv[0], "render/test/");

    TextFormatterApp::Config app_cfg;
    FontConfig font_cfg;
    CommandlineOptions opts;
    opts.add_help("Test application for the texture based text rendering facility "
                  "of archon::render::Application.", "TEXT");
    opts.check_num_args(0,1);
    opts.add_stop_opts();
    opts.add_group(app_cfg);
    opts.add_group(font_cfg, "font");
    if (int stop = opts.process(argc, argv))
        return stop == 2 ? EXIT_SUCCESS : EXIT_FAILURE;

    std::string font_resource_dir = app_cfg.archon_datadir+"font/";
    std::shared_ptr<FontList> font_list = make_font_list(font_resource_dir, font_cfg);
    if (!font_list)
        return EXIT_FAILURE;

    std::wstring text = 1 < argc ? env_decode<wchar_t>(argv[1]) :
        L"The quick brown fox jumps over the lazy dog";

    TextFormatterApp(app_cfg, font_list, text).run();
}
Пример #4
0
int main(int argc, char const *argv[]) throw()
{
  int opt_port = 8008;

  CommandlineOptions o;
  o.add_help("Test Application for the Archon web server");
  o.check_num_args();

  o.add_param("p", "port", opt_port, "Select the port number to bind to");

  if(int stop = o.process(argc, argv)) return stop == 2 ? 0 : 1;

  sys::signal::ignore_signal(SIGPIPE); // Required by the socket server

  Server server;

  server.bind(opt_port);

  return 0;
}
Пример #5
0
int main(int argc, char const *argv[]) throw()
{
  double opt_rate  = 3.3;
  double opt_size  = 3.3;

  CommandlineOptions opts;
  opts.add_help("Test application for slow streams");
  opts.check_num_args();
  opts.add_param("r", "rate", opt_rate,
                 "The average transfer rate in bytes per second");
  opts.add_param("s", "size", opt_size,
                 "Set average chunk size");
  if(int stop = opts.process(argc, argv)) return stop == 2 ? 0 : 1;

  UniquePtr<InputStream>  in(make_stdin_stream().release());
  UniquePtr<OutputStream> out(make_stdout_stream().release());

  out->write(*make_slow_stream(*in, opt_rate, opt_size));

  return 0;
}
Пример #6
0
int main(int argc, const char* argv[]) throw()
{
    std::set_terminate(&cxx::terminate_handler);

    try_fix_preinstall_datadir(argv[0], "image/test/");

    CommandlineOptions opts;
    opts.add_help("Test application for image operator compositions as targets");
    opts.check_num_args();
    opts.add_param("v", "view", opt_view,
                   "Choose from:\n"
                   "ident\n"
//                   "cut,left,bottom,width,height[,horizontalrepeat,verticalrepeat]\n"
                   "flip,horizontal,vertical\n"
                   "diagflip,even,odd\n"
                   "rot,ninety,oneeighty\n"
                   "invert[,index]\n"
                   "channel,index[,preserve-alpha]");
    opts.add_param("i", "image", opt_image, "Image to be written through the selected view");
    if (int stop = opts.process(argc, argv))
        return stop == 2 ? EXIT_SUCCESS : EXIT_FAILURE;

    if (opt_image.empty())
        opt_image = file::dir_of(argv[0])+"../alley_baggett.png";

    Image::Ref image = load_image(*make_stdin_stream(), "stream:in:std");
    Image::Ref view;

    std::vector<int> params;
    if (check_view("ident", opt_view, params)) {
        if (0 < params.size())
            throw std::invalid_argument("Wrong number of view params");
        view = image;
    }
/*
    else if(check_view("cut", opt_view, params)) {
        if (params.size() != 4 && params.size() != 6)
            throw std::invalid_argument("Wrong number of view params");
        if (params.size() == 4) {
            view = image->getSubView(params[0], params[1], params[2], params[3]);
        }
        else {
            view = image->getSubView(params[0], params[1], params[2], params[3], params[4], params[5]);
        }
    }
*/
    else if (check_view("flip", opt_view, params)) {
        if (params.size() != 2)
            throw std::invalid_argument("Wrong number of view params");
        view = Oper::flip(image, params[0], params[1]);
    }
    else if (check_view("diagflip", opt_view, params)) {
        if (params.size() != 2)
            throw std::invalid_argument("Wrong number of view params");
        view = Oper::flip_diag(image, params[0], params[1]);
    }
    else if (check_view("rot", opt_view, params)) {
        if (params.size() != 2)
            throw std::invalid_argument("Wrong number of view params");
        view = Oper::rotate(image, params[0], params[1]);
    }
    else if (check_view("invert", opt_view, params)) {
        if (params.size() != 0 && params.size() != 1)
            throw std::invalid_argument("Wrong number of view params");
        view = params.size() == 0 ? Oper::invert(image) : Oper::invert(image, params[0]);
    }
    else if (check_view("channel", opt_view, params)) {
        if (params.size() != 1 && params.size() != 2)
            throw std::invalid_argument("Wrong number of view params");
        view = params.size() == 1 ? Oper::pick_channel(image, params[0]) :
            Oper::pick_channel(image, params[0], params[1]);
    }
    else {
        throw std::invalid_argument("Unknown view '"+opt_view+"'");
    }

    view->put_image(Image::load(opt_image));

    save_image(image, *make_stdout_stream(), "stream:out:std", "png");
}
Пример #7
0
int main(int argc, const char* argv[])
{
    int               opt_page             = 1;
    Series<2, double> opt_size(512,512);
    PackedTRGB        opt_color            = PackedTRGB(0x000000);
    PackedTRGB        opt_background_color = PackedTRGB(0xFFFFFF);
    PackedTRGB        opt_border_color     = PackedTRGB(0x000000);
    double            opt_margin           = 4;
    int               opt_border           = 1;
    bool              opt_grid_fitting     = true;
    bool              opt_debug            = false;
    bool              opt_mixed            = false;

    FontConfig font_cfg;
    LayoutConfig layout_cfg;
    CommandlineOptions opts;
    opts.add_help("Test application for the font rendering library", "TEXT");
    opts.check_num_args(0,1);
    opts.add_stop_opts();
    opts.add_param("p", "page", opt_page, "The number of the page to be rendered.");
    opts.add_param("S", "size", opt_size,
                   "Maximum page size in number of pixels (width,height). May be fractional. "
                   "If a component is less than or equal to zero, the page is unbounded in "
                   "that direction.");
    opts.add_param("c", "color", opt_color, "Set the text color using any valid CSS3 color value "
                   "(with or without alpha), or the obvious extentension of the hex notation for "
                   "RGBA values.");
    opts.add_param("u", "background-color", opt_background_color, "Set the nackground color using "
                   "any valid CSS3 color value (with or without alpha), or the obvious extentension "
                   "of the hex notation for RGBA values.");
    opts.add_param("o", "border-color", opt_border_color, "Set the border color using any valid "
                   "CSS3 color value (with or without alpha), or the obvious extentension of the "
                   "hex notation for RGBA values.");
    opts.add_param("m", "margin", opt_margin, "Set the width of the margin around the rendered text "
                   "in number of pixels. It does not need not be an integer.");
    opts.add_param("d", "border", opt_border, "Set the width of the border around the rendered text "
                   "in number of pixels.");
    opts.add_group(font_cfg, "font");
    opts.add_group(layout_cfg);
    opts.add_param("g", "grid-fitting", opt_grid_fitting, "Enable grid fitted layout. "
                   "This modifies each glyph slightly to improve the quality of small font sizes.");
    opts.add_param("D", "debug", opt_debug, "Display extra features "
                   "that are helpful when debugging.");
    opts.add_param("M", "mixed", opt_mixed, "Add extra text using a bouquet of font styles "
                   "and colors.");
    if (int stop = opts.process(argc, argv))
        return stop == 2 ? EXIT_SUCCESS : EXIT_FAILURE;

    std::shared_ptr<FontList> list = make_font_list(file::dir_of(argv[0])+"../../", font_cfg);
    if (!list)
        return EXIT_FAILURE;

    std::wstring text = (1 < argc ? env_decode<wchar_t>(argv[1]) :
                         L"The quick brown fox jumps over the lazy dog");
    TextRenderer renderer{new_font_cache(list)};
    renderer.set_page_width(Interval(0, opt_size[0]));
    renderer.set_page_height(Interval(0, opt_size[1]));
    renderer.set_text_color(opt_color);
    renderer.set_background_color(opt_background_color);
    renderer.set_border_color(opt_border_color);
    renderer.set_padding(opt_margin, opt_margin, opt_margin, opt_margin);
    renderer.set_border_width(opt_border, opt_border, opt_border, opt_border);
    layout_cfg.apply_to(renderer);
    renderer.enable_grid_fitting(opt_grid_fitting);
    renderer.write(text);

    if (opt_mixed) {
        renderer.write(L" ");
        renderer.set_text_color(color::red);
        renderer.set_font_size(35, 35);
        renderer.set_font_boldness(1);
        renderer.write(L"Kristian ");
        renderer.set_letter_spacing(10);
        renderer.write(L"Kristian ");

        renderer.set_text_color(color::lime);
        renderer.set_font_size(25, 25);
        renderer.set_font_boldness(0);
        renderer.set_font_italicity(1);
        renderer.write(L"Spangsege ");

        renderer.set_text_color(color::fuchsia);
        renderer.set_font_size(30, 30);
        renderer.set_font_italicity(0);
        renderer.set_font_family("URW Palladio L");
        renderer.write(L"h");
        renderer.set_line_spacing(2);
        renderer.write(L"I");
        renderer.set_line_spacing(1);
        renderer.write(L"gh ");

        renderer.set_text_color(color::blue);
        renderer.set_font_size(45, 45);
        renderer.set_font_family("VL Gothic");
        renderer.write(L"Mandala");
    }

    Image::Ref img = renderer.render(opt_page-1, opt_debug);
    if (!img) {
        std::cerr << "ERROR: No image!\n";
        return EXIT_FAILURE;
    }

    std::string out_file = "/tmp/archon_font_text_render.png";
    img->save(out_file);
    std::cout << "Page "<<opt_page<<" of "<<renderer.get_num_pages()<<" saved to: "
        ""<<out_file<<std::endl;
}