Simple Animated ProgressBar (Terminal | Windows)
import "lib/progressbar.h" and execute code inside a Win Thread ( see example )
gcc sample.c bin/progressbar.c
// define onProgressEnd function
void end(ProgressBar bar){
printf("Completed %d%%!", bar.progress);
Sleep(2500);
// hide with animation (animation type , animation speed in milliseconds)
bar.clearWithAnimation(ANIMATION_ZIG_ZAG, 6);
// do other
}
// create new progressbar
ProgressBar bar = ProgressBarBuilder();
bar.setBackground(&bar, BRIGHT_RED );
bar.setForeground(&bar, BRIGHT_WHITE);
bar.setBarColor(&bar, BAR_WHITE);
bar.setMax(&bar,100); // [REQUIRED] Max Value of Bar
bar.setSize(&bar, 50); // [REQUIRED] Width of Bar
bar.setText(&bar,"Loading Data..."); // [Optional]
bar.setOnEndProgress(&bar,end); // [Optional] Void Function to execute at the end of progress
bar.show(bar);
// change progress
while(progress <= bar.max){
bar.setProgress(&bar, progress++);
Sleep(20); // pause progress
}
- BLACK
- BLUE
- GREEN
- CYAN
- RED
- PURPLE
- YELLOW
- WHITE
- GRAY
- BRIGHT_BLUE
- BRIGHT_GREEN
- BRIGHT_CYAN
- BRIGHT_RED
- BRIGHT_PURPLE
- BRIGHT_YELLOW
- BRIGHT_WHITE
- BAR_BLUE
- BAR_GREEN
- BAR_CYAN
- BAR_RED
- BAR_PURPLE
- BAR_YELLOW
- BAR_WHITE
- BAR_GRAY
Francesco Cannizzaro