FTXUI 6.1.9
C++ functional terminal UI.
Chargement...
Recherche...
Aucune correspondance
color_truecolor_RGB.cpp
Aller à la documentation de ce fichier.
1// Copyright 2020 Arthur Sonzogni. Tous droits réservés.
2// L'utilisation de ce code source est régie par la licence MIT que l'on peut trouver
3// dans le fichier LICENSE.
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
12int 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("Couleurs primaires"),
34 vbox({
35 hbox({text("Ligne rouge :"), hbox(std::move(red_line))}),
36 hbox({text("Ligne verte :"), hbox(std::move(green_line))}),
37 hbox({text("Ligne bleue :"), hbox(std::move(blue_line))}),
38 })),
39 window(text("Couleurs secondaires"),
40 vbox({
41 hbox({text("Ligne cyan :"), hbox(std::move(cyan_line))}),
42 hbox({text("Ligne magenta :"), hbox(std::move(magenta_line))}),
43 hbox({text("Ligne jaune :"), 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}
int main()
auto screen
Element bgcolor(const LinearGradient &gradient, Element child)
Définit la couleur de fond d'un élément avec un effet de dégradé linéaire.
void Render(Screen &screen, const Element &element)
Affiche un élément sur un ftxui::Screen.
Definition node.cpp:83
L'espace de noms FTXUI ftxui::
Definition animation.hpp:10
std::vector< Element > Elements
Definition elements.hpp:23