mirror of
https://github.com/p-ranav/indicators.git
synced 2025-12-12 01:18:52 +08:00
Minor updates. Added logo and demo GIF
This commit is contained in:
@@ -1 +1,4 @@
|
||||
|
||||
<p align="center">
|
||||
<img height="100" src="img/logo.png"/>
|
||||
<img height="100" src="img/demo.gif"/>
|
||||
</p>
|
||||
|
||||
BIN
img/demo.gif
Normal file
BIN
img/demo.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 461 KiB |
BIN
img/logo.png
Normal file
BIN
img/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
@@ -55,7 +55,7 @@ int main() {
|
||||
p1.fill_bar_progress_with("■");
|
||||
p1.lead_bar_progress_with("■");
|
||||
p1.fill_bar_remainder_with(" ");
|
||||
p1.end_bar_with("]");
|
||||
p1.end_bar_with(" ]");
|
||||
p1.set_foreground_color(indica::Color::YELLOW);
|
||||
|
||||
std::atomic<size_t> index1{0};
|
||||
@@ -289,11 +289,11 @@ int main() {
|
||||
indica::ProgressBar p2;
|
||||
p2.set_bar_width(30);
|
||||
p2.set_prefix_text(" - ");
|
||||
p2.start_bar_with("[🌎");
|
||||
p2.fill_bar_progress_with(" ");
|
||||
p2.lead_bar_progress_with("⠁⠂⠄🚀");
|
||||
p2.start_bar_with("🌎");
|
||||
p2.fill_bar_progress_with("·");
|
||||
p2.lead_bar_progress_with("🚀");
|
||||
p2.fill_bar_remainder_with(" ");
|
||||
p2.end_bar_with("🌑]");
|
||||
p2.end_bar_with("🌑");
|
||||
p2.set_postfix_text("Achieved low-Earth orbit");
|
||||
p2.set_foreground_color(indica::Color::WHITE);
|
||||
std::vector<std::string> ship_trail{"⠁", "⠂", "⠄", "⡀", "⢀", "⠠", "⠐", "⠈"};
|
||||
@@ -304,17 +304,11 @@ int main() {
|
||||
if (ticks > 20 && ticks < 50)
|
||||
p2.set_postfix_text("Switching to trans-lunar trajectory");
|
||||
else if (ticks > 50 && ticks < 80)
|
||||
p2.set_postfix_text("Transfered to Lunar lander");
|
||||
p2.set_postfix_text("Transferred to Lunar lander");
|
||||
else if (ticks > 80 && ticks < 98)
|
||||
p2.set_postfix_text("Almost there");
|
||||
else if (ticks >= 98)
|
||||
p2.set_postfix_text("Landed on the Moon");
|
||||
p2.lead_bar_progress_with(
|
||||
ship_trail[(ship_trail_index - 3) % ship_trail.size()] +
|
||||
ship_trail[(ship_trail_index - 2) % ship_trail.size()] +
|
||||
ship_trail[(ship_trail_index - 1) % ship_trail.size()] +
|
||||
ship_trail[ship_trail_index % ship_trail.size()] +
|
||||
"🚀");
|
||||
p2.tick();
|
||||
ship_trail_index += 1;
|
||||
if (p2.is_completed())
|
||||
@@ -1,66 +0,0 @@
|
||||
#include <progress/bar.hpp>
|
||||
#include <vector>
|
||||
|
||||
int main() {
|
||||
|
||||
ProgressBar bar;
|
||||
|
||||
// Configure progress bar
|
||||
bar.bar_width(50);
|
||||
bar.start_with("[");
|
||||
bar.fill_progress_with("■");
|
||||
bar.lead_progress_with("■");
|
||||
bar.fill_remainder_with("-");
|
||||
bar.end_with(" ]");
|
||||
bar.color(ProgressBar::Color::YELLOW);
|
||||
|
||||
// As configured, the bar will look like this:
|
||||
//
|
||||
// [■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■-------------] 70%
|
||||
//
|
||||
//
|
||||
|
||||
std::atomic<size_t> index{0};
|
||||
std::vector<std::string> status_text = {"Rocket.exe is not responding",
|
||||
"Finding a replacement engineer",
|
||||
"Buying more snacks",
|
||||
"Assimilating the modding community",
|
||||
"Crossing fingers",
|
||||
"Porting KSP to a Nokia 3310"
|
||||
"Flexing struts",
|
||||
"Releasing space whales",
|
||||
"Watching paint dry"};
|
||||
|
||||
// Let's say you want to append some status text to the right of the progress bar
|
||||
// You can use bar.append_text(...) to append text to the right
|
||||
//
|
||||
// [■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■-------------] 70% Finding a replacement engineer
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
//
|
||||
|
||||
auto job = [&bar, &index, &status_text]() {
|
||||
while (true) {
|
||||
if (bar.completed()) {
|
||||
break;
|
||||
}
|
||||
bar.append_text(status_text[index % status_text.size()]);
|
||||
bar.tick();
|
||||
index += 1;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
}
|
||||
};
|
||||
|
||||
std::thread first_job(job);
|
||||
std::thread second_job(job);
|
||||
std::thread third_job(job);
|
||||
std::thread last_job(job);
|
||||
|
||||
first_job.join();
|
||||
second_job.join();
|
||||
third_job.join();
|
||||
last_job.join();
|
||||
|
||||
std::cout << "Done\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user