diff --git a/README.md b/README.md index 8b13789..7200fa5 100644 --- a/README.md +++ b/README.md @@ -1 +1,4 @@ - +

+ + +

diff --git a/img/demo.gif b/img/demo.gif new file mode 100644 index 0000000..1cb691c Binary files /dev/null and b/img/demo.gif differ diff --git a/img/logo.png b/img/logo.png new file mode 100644 index 0000000..975b794 Binary files /dev/null and b/img/logo.png differ diff --git a/samples/multiple_bars.cpp b/samples/demo.cpp similarity index 94% rename from samples/multiple_bars.cpp rename to samples/demo.cpp index 4e6b257..6ad4c1f 100644 --- a/samples/multiple_bars.cpp +++ b/samples/demo.cpp @@ -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 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 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()) diff --git a/samples/single_bar.cpp b/samples/single_bar.cpp deleted file mode 100644 index 544d990..0000000 --- a/samples/single_bar.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include -#include - -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 index{0}; - std::vector 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; -}