examples/dom/canvas.cpp

    //Copyright2020ArthurSonzogni.Allrightsreserved.
    //UseofthissourcecodeisgovernedbytheMITlicensethatcanbefoundin
    //theLICENSEfile.
    #include<stdio.h>//forgetchar
    #include<cmath>//forcos
    #include<ftxui/dom/elements.hpp>//forFit,canvas,operator|,border,Element
    #include<ftxui/screen/screen.hpp>//forPixel,Screen
    #include<vector>//forvector,allocator

    #include"ftxui/dom/canvas.hpp"//forCanvas
    #include"ftxui/dom/node.hpp"//forRender
    #include"ftxui/screen/color.hpp"//forColor,Color::Red,Color::Blue,Color::Green,ftxui

    intmain(){
    usingnamespaceftxui;

    autoc=Canvas(100,100);

    c.DrawText(0,0,"Thisisacanvas",[](Pixel&p){
    p.foreground_color=Color::Red;
    p.underlined=true;
    });

    //Triangle:
    c.DrawPointLine(10,10,80,10,Color::Red);
    c.DrawPointLine(80,10,80,40,Color::Blue);
    c.DrawPointLine(80,40,10,10,Color::Green);

    //Circle,notfilledandfilled:
    c.DrawPointCircle(30,50,20);
    c.DrawPointCircleFilled(40,40,10);

    //Plotafunction:
    std::vector<int>ys(100);
    for(intx=0;x<100;x++)
    ys[x]=int(80+20*cos(x*0.2));
    for(intx=0;x<99;x++)
    c.DrawPointLine(x,ys[x],x+1,ys[x+1],Color::Red);

    autodocument=canvas(&c)|border;

    autoscreen=Screen::Create(Dimension::Fit(document));
    Render(screen,document);
    screen.Print();
    getchar();

    return0;
    }