September 2011
M T W T F S S
« Aug   Oct »
 1234
567891011
12131415161718
19202122232425
2627282930  

Categories

Archives

Archives

The Progress Phallus

My friend Ray runs numerical simulations and wanted to have a decent progress bar for his code. A bit of web searching revealed some code, that takes care of this automatically. However, we thought that an ordinary progress bar is simply too conventional. We should gay it up with some ascii art into a beautiful progress phallus!

#include <unistd.h>
#include <iostream>
#include <string>
 
void printProgBar(int percent)
{
    std::string bar;
 
    for (int i = 0; i < 50; i++) {
        if (i < (percent/2)) {
            bar.replace(i, 1, "=");
        } else if (i == (percent/2)) {
            bar.replace(i, 1, "D");
        } else {
            bar.replace(i, 1, " ");
        }
    }
 
    if (percent < 100) {
        std::cout << "\r" "8" << bar << "@ ";
        std::cout.width( 3 );
        std::cout << percent << "%     " << std::flush;
    } else {
        std::cout << "\r" "8" << bar;
        std::cout << "D~~~~ ~~~ ~" << std::flush;
    }
}
 
int main()
{
    for (int i=0; i<=95; i+=10) {
        sleep(1);
        printProgBar(i);
        std::cout << std::endl;
    }
    for (int i=95; i<=100; ++i) {
        sleep(1);
        printProgBar(i);
        std::cout << std::endl;
    }
    std::cout << std::endl;
}
8D                                                 @   0%     
8=====D                                            @  10%     
8==========D                                       @  20%     
8===============D                                  @  30%     
8====================D                             @  40%     
8=========================D                        @  50%     
8==============================D                   @  60%     
8===================================D              @  70%     
8========================================D         @  80%     
8=============================================D    @  90%     
8===============================================D  @  95%     
8================================================D @  96%     
8================================================D @  97%     
8=================================================D@  98%     
8=================================================D@  99%     
8==================================================D~~~~ ~~~ ~

Leave a Reply