color.cpp
memory
utility
ftxui/dom/elements.hpp
ftxui/dom/node_decorator.hpp
ftxui/screen/box.hpp
ftxui/screen/color.hpp
ftxui/screen/screen.hpp
ftxui/dom/canvas.hpp
ftxui/dom/deprecated.hpp
ftxui/dom/direction.hpp
ftxui/dom/elements.hpp
ftxui/dom/flexbox_config.hpp
ftxui/dom/linear_gradient.hpp
ftxui/dom/node.hpp
ftxui/dom/requirement.hpp
ftxui/dom/selection.hpp
ftxui/screen/box.hpp
ftxui/screen/color.hpp
ftxui/screen/image.hpp
ftxui/screen/pixel.hpp
ftxui/screen/screen.hpp
ftxui/screen/string.hpp
ftxui/screen/terminal.hpp
ftxui/util/autoreset.hpp
ftxui/util/ref.hpp
src/ftxui/dom/color.cpp
ftxui/dom/node_decorator.hpp
cstddef
cstdint
ftxui/dom/take_any_args.hpp
functional
memory
optional
sstream
string
unordered_map
utility
variant
vector
ftxui

    //Copyright2020ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include<memory>//formake_shared
    #include<utility>//formove

    #include"ftxui/dom/elements.hpp"//forElement,Decorator,bgcolor,color
    #include"ftxui/dom/node_decorator.hpp"//forNodeDecorator
    #include"ftxui/screen/box.hpp"//forBox
    #include"ftxui/screen/color.hpp"//forColor
    #include"ftxui/screen/screen.hpp"//forPixel,Screen

    namespaceftxui{

    namespace{
    classBgColor:publicNodeDecorator{
    public:
    BgColor(Elementchild,Colorcolor)
    :NodeDecorator(std::move(child)),color_(color){}

    voidRender(Screen&screen)override{
    if(color_.IsOpaque()){
    for(inty=box_.y_min;y<=box_.y_max;++y){
    for(intx=box_.x_min;x<=box_.x_max;++x){
    screen.PixelAt(x,y).background_color=color_;
    }
    }
    }else{
    for(inty=box_.y_min;y<=box_.y_max;++y){
    for(intx=box_.x_min;x<=box_.x_max;++x){
    Color&color=screen.PixelAt(x,y).background_color;
    color=Color::Blend(color,color_);
    }
    }
    }
    NodeDecorator::Render(screen);
    }

    Colorcolor_;
    };

    classFgColor:publicNodeDecorator{
    public:
    FgColor(Elementchild,Colorcolor)
    :NodeDecorator(std::move(child)),color_(color){}

    voidRender(Screen&screen)override{
    if(color_.IsOpaque()){
    for(inty=box_.y_min;y<=box_.y_max;++y){
    for(intx=box_.x_min;x<=box_.x_max;++x){
    screen.PixelAt(x,y).foreground_color=color_;
    }
    }
    }else{
    for(inty=box_.y_min;y<=box_.y_max;++y){
    for(intx=box_.x_min;x<=box_.x_max;++x){
    Color&color=screen.PixelAt(x,y).foreground_color;
    color=Color::Blend(color,color_);
    }
    }
    }
    NodeDecorator::Render(screen);
    }

    Colorcolor_;
    };

    }//namespace

    ///@briefSettheforegroundcolorofanelement.
    ///@paramcolorThecoloroftheoutputelement.
    ///@paramchildTheinputelement.
    ///@returnTheoutputelementcolored.
    ///@ingroupdom
    ///
    ///###Example
    ///
    ///```cpp
    ///Elementdocument=color(Color::Green,text("Success")),
    ///```
    Elementcolor(Colorcolor,Elementchild){
    returnstd::make_shared<FgColor>(std::move(child),color);
    }

    ///@briefSetthebackgroundcolorofanelement.
    ///@paramcolorThecoloroftheoutputelement.
    ///@paramchildTheinputelement.
    ///@returnTheoutputelementcolored.
    ///@ingroupdom
    ///
    ///###Example
    ///
    ///```cpp
    ///Elementdocument=bgcolor(Color::Green,text("Success")),
    ///```
    Elementbgcolor(Colorcolor,Elementchild){
    returnstd::make_shared<BgColor>(std::move(child),color);
    }

    ///@briefDecorateusingaforegroundcolor.
    ///@paramcTheforegroundcolortobeapplied.
    ///@returnTheDecoratorapplyingthecolor.
    ///@ingroupdom
    ///
    ///###Example
    ///
    ///```cpp
    ///Elementdocument=text("red")|color(Color::Red);
    ///```
    Decoratorcolor(Colorc){
    return[c](Elementchild){returncolor(c,std::move(child));};
    }

    ///@briefDecorateusingabackgroundcolor.
    ///@paramcolorThebackgroundcolortobeapplied.
    ///@returnTheDecoratorapplyingthecolor.
    ///@ingroupdom
    ///
    ///###Example
    ///
    ///```cpp
    ///Elementdocument=text("red")|bgcolor(Color::Red);
    ///```
    Decoratorbgcolor(Colorcolor){
    return[color](Elementchild){returnbgcolor(color,std::move(child));};
    }

    }//namespaceftxui