xtd 0.2.0
Loading...
Searching...
No Matches
xtd::background_color Class Referencefinal
Inheritance diagram for xtd::background_color:
xtd::object

Definition

Represent background color output manipulator class.

Header
#include <xtd/background_color>
Namespace
xtd
Library
xtd.core
See also
xtd::console::background_color method.
Examples
The following example saves the values of the xtd::console_color enumeration to an array and stores the current values of the xtd::background_color and xtd::foreground_color properties to variables. It then changes the foreground color to each color in the xtd::console_color enumeration except to the color that matches the current background, and it changes the background color to each color in the xtd::console_color enumeration except to the color that matches the current foreground. (If the foreground color is the same as the background color, the text isn't visible.) Finally, it calls the xtd::reset_color class to restore the original console colors.
#include <xtd/background_color>
#include <xtd/foreground_color>
#include <xtd/reset_color>
using namespace std;
using namespace xtd;
auto main()->int {
const auto logo = vector {
u8"████████████████████████████████████████████████████████████",
u8"██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░██████",
u8"██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░████░░████████",
u8"██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░████░░██████████",
u8"██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░████░░████████████",
u8"██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░████░░████████████",
u8"██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░████░░████████████",
u8"███████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░█████████████",
u8"██████████████████████████████████████████████████████████████████████",
u8"██████████████████████████████████████████████████████████████████████",
u8"██████████████████████████▀▄▄▄▄▀███████▀▄▄▄▄▀█████████████████████████",
u8"███████████████████████████▀▀▀▀███████▀▀▀▀▀███████████████████████████",
u8"██████████████████████████ ▀████ ▀█████████████████████████",
u8"███████████ ▐ ▀▀ ▐ ██████████",
u8"█████████ ▐ ███ ▌▐ ███ ▐ █████████",
u8"█████████ ▐ █▄▄▌ ▌▐ ▐▄▄█ ▐ █████████",
u8"█████████ ▐▄ ▀▀ ▄▀ ▀▄ ▀▀ ▄▀ █████████",
u8"█████████ ▀▀▄▄▀ ▀▀▄▄▀ █████████",
u8"█████████ █████████",
u8"█████████ █▄ ▌ █████████",
u8"█████████ ▌▀▀▄ ▄██ █████████",
u8"█████████ ▐ ▀▀▄▄▄▄▄▄█▀ █▌ █████████",
u8"█████████ ▐ ▄█ █████████",
u8"█████████ █ ▄█ █████████",
u8"█████████ ▀▄ █▀ █████████",
u8"█████████ ▀▄▄▄▄██▀ █████████",
u8"█████████ █████████",
u8"█████████ █████████",
u8"█████████ █████████",
u8"█████████ █████████",
u8"█████████ █████████",
u8"██████████████████████████████████████████████████████████████████",
};
for (auto index = 0ul; index < logo.size(); ++index)
cout << (index == 0 || index == logo.size() - 1 ? " " : " ") << background_color(console_color::white) << foreground_color(console_color::dark_blue) << logo[index] << reset_color() << endl;
cout << foreground_color(console_color::dark_blue) << " Gammasoft " << endl;
cout << foreground_color(console_color::dark_gray) << " More than thirty years of passion for high technology especially in development" << endl;
cout << " (c++, c#, objective-c, ...)." << reset_color() << endl;
}
// This code produces the following output with colors:
//
// ████████████████████████████████████████████████████████████
// ██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░██████
// ██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░████░░████████
// ██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░████░░██████████
// ██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░████░░████████████
// ██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░████░░████████████
// ██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░████░░████████████
// ███████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░█████████████
// ██████████████████████████████████████████████████████████████████████
// ██████████████████████████████████████████████████████████████████████
// ██████████████████████████▀▄▄▄▄▀███████▀▄▄▄▄▀█████████████████████████
// ███████████████████████████▀▀▀▀███████▀▀▀▀▀███████████████████████████
// ██████████████████████████ ▀████ ▀█████████████████████████
// ███████████ ▐ ▀▀ ▐ ██████████
// █████████ ▐ ███ ▌▐ ███ ▐ █████████
// █████████ ▐ █▄▄▌ ▌▐ ▐▄▄█ ▐ █████████
// █████████ ▐▄ ▀▀ ▄▀ ▀▄ ▀▀ ▄▀ █████████
// █████████ ▀▀▄▄▀ ▀▀▄▄▀ █████████
// █████████ █████████
// █████████ █▄ ▌ █████████
// █████████ ▌▀▀▄ ▄██ █████████
// █████████ ▐ ▀▀▄▄▄▄▄▄█▀ █▌ █████████
// █████████ ▐ ▄█ █████████
// █████████ █ ▄█ █████████
// █████████ ▀▄ █▀ █████████
// █████████ ▀▄▄▄▄██▀ █████████
// █████████ █████████
// █████████ █████████
// █████████ █████████
// █████████ █████████
// █████████ █████████
// ██████████████████████████████████████████████████████████████████
// Gammasoft
// More than thirty years of passion for high technology especially in development
// (c++, c#, objective-c, ...).
Represent background color output manipulator class.
Definition background_color.h:22
static int32 output_code_page()
Gets the code page the console uses to write output.
Represent foreground color output manipulator class.
Definition foreground_color.h:20
Represent reset color output manipulator class.
Definition reset_color.h:20
console_color
Specifies constants that define foreground and background colors for the console.
Definition console_color.h:18
@ dark_blue
The color dark blue.
@ dark_gray
The color dark gray.
@ white
The color white.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Examples
console_background_color2.cpp, console_background_color3.cpp, console_color3.cpp, console_color4.cpp, hello_world_console2.cpp, hello_world_console3.cpp, and owner_button.cpp.

Public Constructors

 background_color (console_color color)
 Sets the background color of the console.
 

Additional Inherited Members

- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object.
 
bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object.
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type.
 
virtual type_object get_type () const noexcept
 Gets the type of the current instance.
 
template<typename object_t >
std::unique_ptr< object_t > memberwise_clone () const noexcept
 Creates a shallow copy of the current object.
 
virtual xtd::ustring to_string () const noexcept
 Returns a sxd::ustring that represents the current object.
 
- Static Public Member Functions inherited from xtd::object
static bool equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
static bool reference_equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 

Constructor & Destructor Documentation

◆ background_color()

xtd::background_color::background_color ( console_color  color)
inlineexplicit

Sets the background color of the console.

Parameters
colorA xtd::console_color that specifies the background color of the console; that is, the color that appears behind each character.
Remarks
A change to the background_color method affects only output that is written to individual character cells after the background color is changed. To change the background color of the console window as a whole, set the BackgroundColor property and call the Clear method. The following example provides an illustration.
Examples
The following example saves the values of the xtd::console_color enumeration to an array and stores the current values of the xtd::background_color and xtd::foreground_color properties to variables. It then changes the foreground color to each color in the xtd::console_color enumeration except to the color that matches the current background, and it changes the background color to each color in the xtd::console_color enumeration except to the color that matches the current foreground. (If the foreground color is the same as the background color, the text isn't visible.) Finally, it calls the xtd::reset_color class to restore the original console colors.
#include <xtd/background_color>
#include <xtd/foreground_color>
#include <xtd/reset_color>
using namespace std;
using namespace xtd;
auto main()->int {
const auto logo = vector {
u8"████████████████████████████████████████████████████████████",
u8"██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░██████",
u8"██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░████░░████████",
u8"██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░████░░██████████",
u8"██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░████░░████████████",
u8"██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░████░░████████████",
u8"██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░████░░████████████",
u8"███████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░█████████████",
u8"██████████████████████████████████████████████████████████████████████",
u8"██████████████████████████████████████████████████████████████████████",
u8"██████████████████████████▀▄▄▄▄▀███████▀▄▄▄▄▀█████████████████████████",
u8"███████████████████████████▀▀▀▀███████▀▀▀▀▀███████████████████████████",
u8"██████████████████████████ ▀████ ▀█████████████████████████",
u8"███████████ ▐ ▀▀ ▐ ██████████",
u8"█████████ ▐ ███ ▌▐ ███ ▐ █████████",
u8"█████████ ▐ █▄▄▌ ▌▐ ▐▄▄█ ▐ █████████",
u8"█████████ ▐▄ ▀▀ ▄▀ ▀▄ ▀▀ ▄▀ █████████",
u8"█████████ ▀▀▄▄▀ ▀▀▄▄▀ █████████",
u8"█████████ █████████",
u8"█████████ █▄ ▌ █████████",
u8"█████████ ▌▀▀▄ ▄██ █████████",
u8"█████████ ▐ ▀▀▄▄▄▄▄▄█▀ █▌ █████████",
u8"█████████ ▐ ▄█ █████████",
u8"█████████ █ ▄█ █████████",
u8"█████████ ▀▄ █▀ █████████",
u8"█████████ ▀▄▄▄▄██▀ █████████",
u8"█████████ █████████",
u8"█████████ █████████",
u8"█████████ █████████",
u8"█████████ █████████",
u8"█████████ █████████",
u8"██████████████████████████████████████████████████████████████████",
};
for (auto index = 0ul; index < logo.size(); ++index)
cout << (index == 0 || index == logo.size() - 1 ? " " : " ") << background_color(console_color::white) << foreground_color(console_color::dark_blue) << logo[index] << reset_color() << endl;
cout << foreground_color(console_color::dark_blue) << " Gammasoft " << endl;
cout << foreground_color(console_color::dark_gray) << " More than thirty years of passion for high technology especially in development" << endl;
cout << " (c++, c#, objective-c, ...)." << reset_color() << endl;
}
// This code produces the following output with colors:
//
// ████████████████████████████████████████████████████████████
// ██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░██████
// ██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░████░░████████
// ██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░████░░██████████
// ██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░████░░████████████
// ██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░████░░████████████
// ██████████████████████████████░░░░░░░░░░░░░░░░░░░░░░████░░████████████
// ███████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░█████████████
// ██████████████████████████████████████████████████████████████████████
// ██████████████████████████████████████████████████████████████████████
// ██████████████████████████▀▄▄▄▄▀███████▀▄▄▄▄▀█████████████████████████
// ███████████████████████████▀▀▀▀███████▀▀▀▀▀███████████████████████████
// ██████████████████████████ ▀████ ▀█████████████████████████
// ███████████ ▐ ▀▀ ▐ ██████████
// █████████ ▐ ███ ▌▐ ███ ▐ █████████
// █████████ ▐ █▄▄▌ ▌▐ ▐▄▄█ ▐ █████████
// █████████ ▐▄ ▀▀ ▄▀ ▀▄ ▀▀ ▄▀ █████████
// █████████ ▀▀▄▄▀ ▀▀▄▄▀ █████████
// █████████ █████████
// █████████ █▄ ▌ █████████
// █████████ ▌▀▀▄ ▄██ █████████
// █████████ ▐ ▀▀▄▄▄▄▄▄█▀ █▌ █████████
// █████████ ▐ ▄█ █████████
// █████████ █ ▄█ █████████
// █████████ ▀▄ █▀ █████████
// █████████ ▀▄▄▄▄██▀ █████████
// █████████ █████████
// █████████ █████████
// █████████ █████████
// █████████ █████████
// █████████ █████████
// ██████████████████████████████████████████████████████████████████
// Gammasoft
// More than thirty years of passion for high technology especially in development
// (c++, c#, objective-c, ...).

The documentation for this class was generated from the following file: