MCPcopy
hub / github.com/shzlw/zeu / drawObject

Method drawObject

src/text-meter.js:51–116  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49 }
50
51 drawObject() {
52 this._ctx.globalCompositeOperation = 'destination-over';
53
54 // Draw left half text
55 this._ctx.beginPath();
56 this._ctx.rect(this._arrowWidth, this._pctHeight, this._barX - this._arrowWidth, this._meterHeight);
57 this._ctx.clip();
58
59 this._shape.fillText(this.displayValue, this._viewWidth / 2, 75, '30px Arial', 'center', this.bgColor);
60
61 this._ctx.fillStyle = this.fillColor;
62 this._ctx.fillRect(this._arrowWidth, this._pctHeight, this._barX - this._arrowWidth, this._meterHeight);
63
64 this._ctx.restore();
65 this.save();
66 this._ctx.globalCompositeOperation = 'destination-over';
67
68 // Draw right half text
69 this._ctx.beginPath();
70 this._ctx.rect(this._barX, this._pctHeight, this._viewWidth - this._barX - this._arrowWidth, this._meterHeight);
71 this._ctx.clip();
72
73 this._shape.fillText(this.displayValue, this._viewWidth / 2, 75, '30px Arial', 'center', this.fillColor);
74
75 this._shape.fillRect(this._barX, this._pctHeight, this._viewWidth - this._barX - this._arrowWidth,
76 this._meterHeight, this.bgColor);
77
78 this._ctx.restore();
79 this.save();
80 this._ctx.globalCompositeOperation = 'source-over';
81
82 // Draw the border.
83 this._ctx.lineWidth = this._lineWidth;
84 this._ctx.strokeStyle = this._lineColor;
85 this._ctx.beginPath();
86 this._ctx.rect(this._arrowWidth, this._pctHeight, this._meterWidth, this._meterHeight);
87 this._ctx.stroke();
88 this._ctx.closePath();
89
90 // Draw percentage value
91 this._ctx.fillStyle = this.markerBgColor;
92
93 this._ctx.fillRect(this._barX - 25, 0, 50, this._actualPctHeight);
94 this._shape.fillText(this._percentageValue + '%', this._barX, 20, '16px Arial', 'center', this.markerFontColor);
95
96 this._ctx.beginPath();
97 this._ctx.fillStyle = this.markerBgColor;
98 this._ctx.moveTo(this._barX - 8, this._actualPctHeight - this._lineWidth / 2);
99 this._ctx.lineTo(this._barX, this._pctHeight + this._lineWidth / 2);
100 this._ctx.lineTo(this._barX + 8, this._actualPctHeight - this._lineWidth / 2);
101 this._ctx.fill();
102 this._ctx.closePath();
103
104 // Draw arrow.
105 if (this._arrow === null) {
106 this.drawLeftArrow();
107 this.drawRightArrow();
108 } else if (this._arrow === 'left') {

Callers

nothing calls this directly

Calls 7

drawLeftArrowMethod · 0.95
drawRightArrowMethod · 0.95
fillTextMethod · 0.80
fillRectMethod · 0.80
saveMethod · 0.80
moveToMethod · 0.80
getNextPosMethod · 0.80

Tested by

no test coverage detected