-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
23 lines (21 loc) · 745 Bytes
/
Copy pathscript.js
File metadata and controls
23 lines (21 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var BORDER_WIDTH = 8;
var GAP_WIDTH = 4;
var OFFSET = BORDER_WIDTH * 2 + GAP_WIDTH * 2;
function draw() {
var canvas = document.getElementById('progress-bar');
var ctx = canvas.getContext('2d');
ctx.lineWidth = BORDER_WIDTH;
ctx.strokeRect(BORDER_WIDTH / 2, BORDER_WIDTH / 2, canvas.width - BORDER_WIDTH, canvas.height - BORDER_WIDTH);
var origin = BORDER_WIDTH + GAP_WIDTH;
var x = origin;
var y = origin;
var barHeight = canvas.height - OFFSET;
var barWidth = (canvas.width - BORDER_WIDTH * 2 - GAP_WIDTH) / 20 - GAP_WIDTH;
for (i = 0; i < 20; i++) {
x = origin + (barWidth + GAP_WIDTH) * i;
ctx.fillRect(x, y, barWidth, barHeight);
}
}
window.onload = function() {
draw();
};