Skip to content

Commit

Permalink
Add progress bar display
Browse files Browse the repository at this point in the history
  • Loading branch information
codefrau committed Sep 4, 2014
1 parent 0322a2a commit 96d7dba
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/squeak.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,21 @@ function createSqueakDisplay(canvas, options) {
ctx.textBaseline = "middle";
ctx.fillText(msg, canvas.width / 2, canvas.height / 2);
};
display.showProgress = function(value, style) {
style = style || {};
var ctx = display.context,
w = (canvas.width / 3) | 0,
h = 24,
x = canvas.width * 0.5 - w / 2,
y = canvas.height * 0.5 + 2 * h;
ctx.fillStyle = style.background || "#000";
ctx.fillRect(x, y, w, h);
ctx.lineWidth = 2;
ctx.strokeStyle = style.color || "#F90";
ctx.strokeRect(x, y, w, h);
ctx.fillStyle = style.color || "#F90";
ctx.fillRect(x, y, w * value, h);
};
canvas.onmousedown = function(evt) {
checkFullscreen();
canvas.focus();
Expand Down

0 comments on commit 96d7dba

Please sign in to comment.