FTXUI 6.1.9 C++ functional terminal UI.

Loading...
Searching...
No Matches
color_truecolor_RGB.cpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#include <ftxui/dom/elements.hpp> // for hbox, text, bgcolor, operator|, vbox, Elements, window, Element, Fit
5#include <ftxui/screen/screen.hpp> // for Full, Screen
6#include <memory> // for allocator
7#include <utility> // for move
8
9#include "ftxui/dom/node.hpp" // for Render
10#include "ftxui/screen/color.hpp" // for Color, ftxui
11
12 int main() {
13 using namespace ftxui;
14
15 Elements red_line;
16 Elements green_line;
17 Elements blue_line;
18 Elements cyan_line;
19 Elements magenta_line;
20 Elements yellow_line;
21
22 for (int value = 0; value < 255; value += 3) {
23 int v = value * value / 255;
24 red_line.push_back(text(" ") | bgcolor(Color::RGB(v, 0, 0)));
25 green_line.push_back(text(" ") | bgcolor(Color::RGB(0, v, 0)));
26 blue_line.push_back(text(" ") | bgcolor(Color::RGB(0, 0, v)));
27 cyan_line.push_back(text(" ") | bgcolor(Color::RGB(0, v, v)));
28 magenta_line.push_back(text(" ") | bgcolor(Color::RGB(v, 0, v)));
29 yellow_line.push_back(text(" ") | bgcolor(Color::RGB(v, v, 0)));
30 }
31
32 auto document = vbox({
33 window(text("Primary colors"),
34 vbox({
35 hbox({text("Red line :"), hbox(std::move(red_line))}),
36 hbox({text("Green line :"), hbox(std::move(green_line))}),
37 hbox({text("Blue line :"), hbox(std::move(blue_line))}),
38 })),
39 window(text("Secondary colors"),
40 vbox({
41 hbox({text("cyan line :"), hbox(std::move(cyan_line))}),
42 hbox({text("magenta line:"), hbox(std::move(magenta_line))}),
43 hbox({text("Yellow line :"), hbox(std::move(yellow_line))}),
44 })),
45 });
46
47 auto screen = Screen::Create(Dimension::Full(), Dimension::Fit(document));
48 Render(screen, document);
49
50 screen.Print();
51
52 return 0;
53}
color.hpp
main
int main()
Definition color_truecolor_RGB.cpp:12
elements.hpp
ftxui
The FTXUI ftxui:: namespace.
Definition animation.hpp:10
ftxui::Elements
std::vector< Element > Elements
Definition elements.hpp:23
node.hpp
screen.hpp