examples/dom/color_gallery.cpp

    //Copyright2020ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include<ftxui/screen/color_info.hpp>//forColorInfo
    #include<ftxui/screen/screen.hpp>//forFull,Screen
    #include<ftxui/screen/terminal.hpp>//forColorSupport,Color,Palette16,Palette256,TrueColor
    #include<memory>//forallocator,shared_ptr
    #include<utility>//formove
    #include<vector>//forvector

    #include"ftxui/dom/elements.hpp"//fortext,bgcolor,color,vbox,hbox,separator,operator|,Elements,Element,Fit,border
    #include"ftxui/dom/node.hpp"//forRender
    #include"ftxui/screen/color.hpp"//forColor,Color::Black,Color::Blue,Color::BlueLight,Color::Cyan,Color::CyanLight,Color::Default,Color::GrayDark,Color::GrayLight,Color::Green,Color::GreenLight,Color::Magenta,Color::MagentaLight,Color::Red,Color::RedLight,Color::White,Color::Yellow,Color::YellowLight,Color::Palette256,ftxui

    usingnamespaceftxui;
    #include"./color_info_sorted_2d.ipp"//forColorInfoSorted2D

    intmain(){
    //clang-formatoff
    autobasic_color_display=
    vbox(
    text("16colorpalette:"),
    separator(),
    hbox(
    vbox(
    color(Color::Default,text("Default")),
    color(Color::Black,text("Black")),
    color(Color::GrayDark,text("GrayDark")),
    color(Color::GrayLight,text("GrayLight")),
    color(Color::White,text("White")),
    color(Color::Blue,text("Blue")),
    color(Color::BlueLight,text("BlueLight")),
    color(Color::Cyan,text("Cyan")),
    color(Color::CyanLight,text("CyanLight")),
    color(Color::Green,text("Green")),
    color(Color::GreenLight,text("GreenLight")),
    color(Color::Magenta,text("Magenta")),
    color(Color::MagentaLight,text("MagentaLight")),
    color(Color::Red,text("Red")),
    color(Color::RedLight,text("RedLight")),
    color(Color::Yellow,text("Yellow")),
    color(Color::YellowLight,text("YellowLight"))
    ),
    vbox(
    bgcolor(Color::Default,text("Default")),
    bgcolor(Color::Black,text("Black")),
    bgcolor(Color::GrayDark,text("GrayDark")),
    bgcolor(Color::GrayLight,text("GrayLight")),
    bgcolor(Color::White,text("White")),
    bgcolor(Color::Blue,text("Blue")),
    bgcolor(Color::BlueLight,text("BlueLight")),
    bgcolor(Color::Cyan,text("Cyan")),
    bgcolor(Color::CyanLight,text("CyanLight")),
    bgcolor(Color::Green,text("Green")),
    bgcolor(Color::GreenLight,text("GreenLight")),
    bgcolor(Color::Magenta,text("Magenta")),
    bgcolor(Color::MagentaLight,text("MagentaLight")),
    bgcolor(Color::Red,text("Red")),
    bgcolor(Color::RedLight,text("RedLight")),
    bgcolor(Color::Yellow,text("Yellow")),
    bgcolor(Color::YellowLight,text("YellowLight"))
    )
    )
    );

    //clang-formaton
    autopalette_256_color_display=text("256colorspalette:");
    {
    std::vector<std::vector<ColorInfo>>info_columns=ColorInfoSorted2D();
    Elementscolumns;
    for(auto&column:info_columns){
    Elementscolumn_elements;
    for(auto&it:column){
    column_elements.push_back(
    text("")|bgcolor(Color(Color::Palette256(it.index_256))));
    }
    columns.push_back(hbox(std::move(column_elements)));
    }
    palette_256_color_display=vbox({
    palette_256_color_display,
    separator(),
    vbox(columns),
    });
    }

    //Truecolordisplay.
    autotrue_color_display=text("TrueColors:24bits:");
    {
    constintmax_value=255;
    constintvalue_increment=8;
    constinthue_increment=6;
    intsaturation=max_value;
    Elementsarray;
    for(intvalue=0;value<max_value;value+=2*value_increment){
    Elementsline;
    for(inthue=0;hue<max_value;hue+=hue_increment){
    line.push_back(
    text("▀")//
    |color(Color::HSV(hue,saturation,value))//
    |bgcolor(Color::HSV(hue,saturation,value+value_increment)));
    }
    array.push_back(hbox(std::move(line)));
    }
    true_color_display=vbox({
    true_color_display,
    separator(),
    vbox(std::move(array)),
    });
    }

    autoterminal_info=
    vbox({
    Terminal::ColorSupport()>=Terminal::Color::Palette16
    ?text("16colorpalettesupport:Yes")
    :text("16colorpalettesupport:No"),
    Terminal::ColorSupport()>=Terminal::Color::Palette256
    ?text("256colorpalettesupport:Yes")
    :text("256colorpalettesupport:No"),
    Terminal::ColorSupport()>=Terminal::Color::TrueColor
    ?text("Truecolorsupport:Yes")
    :text("Truecolorsupport:No"),
    })|
    border;

    autodocument=vbox({hbox({
    basic_color_display,
    text(""),
    palette_256_color_display,
    text(""),
    true_color_display,
    }),
    terminal_info});
    //clang-formaton

    autoscreen=Screen::Create(Dimension::Full(),Dimension::Fit(document));
    Render(screen,document);

    screen.Print();

    return0;
    }