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

Method drawObject

src/text-box.js:42–92  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40 }
41
42 drawObject() {
43 this._ctx.textAlign = 'center';
44
45 // Draw wave line
46 if (this._isWaveOn) {
47 const waveWidth = 1;
48
49 if (this._waveY >= ((this._viewHeight / 2) + waveWidth)) {
50 this._waveY = 0;
51 this._isWaveOn = false;
52 } else {
53 this._ctx.fillStyle = this.waveColor;
54 this._ctx.beginPath();
55 this._ctx.fillRect(0, this._waveY, this._viewWidth + waveWidth, waveWidth);
56 this._ctx.closePath();
57
58 this._ctx.beginPath();
59 this._ctx.fillRect(0, this._viewHeight - this._waveY - waveWidth, this._viewWidth, waveWidth);
60 this._ctx.closePath();
61 this._waveY = Utility.getNextPos(this._waveY, this._viewHeight / 2 + waveWidth, this._waveSpeed);
62 }
63 }
64
65 // Draw the border.
66 // Top left
67 this._ctx.fillStyle = this.borderColor;
68 this._ctx.fillRect(0, 0, this._borderHeight, this._borderWidth);
69 this._ctx.fillRect(0, 0, this._borderWidth, this._borderHeight);
70 // Bottom left
71 this._ctx.fillRect(0, this._viewHeight - this._borderHeight, this._borderWidth, this._borderHeight);
72 this._ctx.fillRect(0, this._viewHeight - this._borderWidth, this._borderHeight, this._borderWidth);
73 // Top right
74 this._ctx.fillRect(this._viewWidth - this._borderHeight, 0, this._borderHeight, this._borderWidth);
75 this._ctx.fillRect(this._viewWidth - this._borderWidth, 0, this._borderWidth, this._borderHeight);
76
77 // Bottom right
78 this._ctx.fillRect(this._viewWidth - this._borderHeight, this._viewHeight - this._borderWidth,
79 this._borderHeight, this._borderWidth);
80 this._ctx.fillRect(this._viewWidth - this._borderWidth, this._viewHeight - this._borderHeight,
81 this._borderWidth, this._borderHeight);
82
83 // Draw background rect.
84 this._ctx.fillStyle = this.textBgColor;
85 this._ctx.fillRect(this._borderWidth + this._space, this._borderWidth + this._space,
86 this._viewWidth - 2 * (this._borderWidth + this._space),
87 this._viewHeight - 2 * (this._borderWidth + this._space));
88
89 // Draw text.
90 this._shape.fillText(this._textValue, this._viewWidth / 2, this._viewHeight - 35,
91 '40px Arial', 'center', this.textColor);
92 }
93
94 set value(s) {
95 this._textValue = s;

Callers

nothing calls this directly

Calls 3

fillRectMethod · 0.80
getNextPosMethod · 0.80
fillTextMethod · 0.80

Tested by

no test coverage detected