| 24 | } |
| 25 | |
| 26 | drawObject() { |
| 27 | // Bars can be seen in the view |
| 28 | const bars = Math.floor(this._viewHeight / (this._barHeight + this._space)); |
| 29 | const drawQueueSize = Math.min(this._queue.length, bars); |
| 30 | |
| 31 | for (let i = 0; i < drawQueueSize; i++) { |
| 32 | let q = this._queue[i]; |
| 33 | |
| 34 | let currY = (this._barHeight + this._space) * i + this._space; |
| 35 | |
| 36 | // Move up |
| 37 | if (currY < q.y) { |
| 38 | q.y -= this._speed; |
| 39 | } else { |
| 40 | q.y = currY; |
| 41 | } |
| 42 | |
| 43 | this._shape.fillRect(q.x, q.y, this._viewWidth - 2 * (this._arcWidth + q.space), this._barHeight, q.color); |
| 44 | |
| 45 | this._ctx.beginPath(); |
| 46 | this._ctx.moveTo(q.x, q.y); |
| 47 | this._ctx.quadraticCurveTo(q.x - this._arcWidth, q.y + this._barHeight / 2, q.x, q.y + this._barHeight); |
| 48 | this._ctx.fill(); |
| 49 | this._ctx.closePath(); |
| 50 | this._ctx.beginPath(); |
| 51 | this._ctx.moveTo(this._viewWidth - this._arcWidth - q.space, q.y); |
| 52 | this._ctx.quadraticCurveTo(this._viewWidth - q.space, q.y + this._barHeight / 2, |
| 53 | this._viewWidth - this._arcWidth - q.space, q.y + this._barHeight); |
| 54 | this._ctx.fill(); |
| 55 | this._ctx.closePath(); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | push(param = {}) { |
| 60 | const barColor = param.color || COLOR.blue; |