backwards progress bar
in
Programming Questions
•
1 year ago
hi, im trying to create a progress bar (much like a few others on the forum from a quick look) for a uni assignment...not sure how "legal" it is to put direct code on here but its in the last few days before the deadline.
Basically i have a backwards running progress bar (starts black then the opacity fades as (from what i can gather) the white lines are drawn to overwrite the opaque black bar (again i stress "think" :P)
just wondering about how to go about fixing this?
int LineDrawnHereXCoordinate = 0;
float startTime = 0;
int barLoadComplete = 245;
float amountDone = 0;
float opacity;
int count = 0;
float progress =random(2000,8000);
float percentageDone;
void drawProgressBar(float x, float y, float w, float h) {
fill(255);
stroke(0) ;
rectMode(CORNER);
rect(width*.25, height*.45, width*.52, height*.1);
for (float i= x + LineDrawnHereXCoordinate; i < x + 250;i++) {
stroke(0, opacity) ;
percentageDone = i/250;
line(i, y, i, y+h);
/*println("percentageDone");*/
}
opacity++;
LineDrawnHereXCoordinate++;
if (x == barLoadComplete) {
stroke(0);
text("100% Done!", width*.255, height*.46, width*.48, height*.08);
}
}
void setup() {
size(500, 300);
background(255);
textSize(20);
textAlign(CENTER);
fill(0) ;
}
void draw() {
drawProgressBar(width*.255, height*.46, width*.48, height*.08);
if (millis() - progress >=0 && count<100)
{count=count+5;
}
fill(0);
text(Float.toString((5*progress/5))+"%", width*.255, height*.46, width*.48, height*.08);
}
1