cnjinhao / nana

a modern C++ GUI library
https://nana.acemind.cn
Boost Software License 1.0
2.33k stars 335 forks source link

need examples for nana #520

Open mohammed-altmimi opened 4 years ago

mohammed-altmimi commented 4 years ago

hi is there a simple example for paint::image or "animation" and is there a good book for nana lib of good tutorial

kassane commented 4 years ago

https://qpcr4vir.github.io/nana-doxy/html/d0/deb/animate-bmp_8cpp-example.html

#include <nana/gui.hpp>
#include <nana/gui/animation.hpp>
int main()
{
    using namespace nana;

    //Build frames
    frameset fset;
    auto grs = {"000", "015", "030", "045", "060", "075", "090", "105", "120", "135", "150", "170",
                "180", "195", "210", "225", "240", "260", "270", "285", "300", "315", "330", "345"};
    for (const auto& gr: grs)
        fset.push_back(nana::paint::image(std::string("../Examples/a_pic")+gr+".bmp"));
    //A widget to display animation.
    form fm;
    fm.show();
    animation ani;
    ani.push_back(fset);
    ani.output(fm, nana::point());
    ani.looped(true);
    ani.play();
    exec();

https://qpcr4vir.github.io/nana-doxy/html/df/d21/draw_8cpp-example.html

#include <nana/gui.hpp>
int main()
{
    using namespace nana;
    form fm {API::make_center(340, 340)};
    drawing dw(fm);
    dw.draw([](paint::graphics& graph)
    {
        graph.rectangle(rectangle{5, 5, 50, 50}, true, colors::red );
        graph.line(point(5, 5), point(55, 55), colors::blue);
        graph.line_begin(200,100);
        graph.line_to(point(300,300));
        graph.line_to(point(100,200));
        graph.line_to(point(300,200));
        graph.line_to(point(100,300));
        graph.line_to(point(200,100));
                graph.save_as_file("graphics.bmp");
                nana::paint::image img("test.bmp");
                if (img.empty())
                {
                        graph.line(point(100, 100), point(300, 100), colors::red);
                        graph.save_as_file("test.bmp");
                }
                else 
                        img.paste(nana::rectangle(img.size()), graph, nana::point());
                graph.save_as_file("testGraphics.bmp");
    });
        nana::paint::graphics graphics;
        nana::paint::image img("test.bmp");
        if (!img.empty())
        {
                img.paste(nana::rectangle(img.size()), graphics, nana::point());
                graphics.save_as_file("testGraphics2.bmp");
        }
        dw.update();
    fm.show();
    ::nana::exec();
mohammed-altmimi commented 4 years ago

thank you

ErrorFlynn commented 4 years ago

is there a good book for nana lib of good tutorial

I've been working on a more detailed alternative for the documentation, that includes examples. It's far from complete, but you may find it useful: https://errorflynn.github.io/nana-docs/ It's not designed for mobile devices at the moment (use desktop to view).

mohammed-altmimi commented 4 years ago

is there a good book for nana lib of good tutorial

I've been working on a more detailed alternative for the documentation, that includes examples. It's far from complete, but you may find it useful: https://errorflynn.github.io/nana-docs/ It's not designed for mobile devices at the moment (use desktop to view).

thank you

mohammed-altmimi commented 4 years ago

I've been working on a more detailed alternative for the documentation, that includes examples. It's far from complete, but you may find it useful:

very good work