MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / drawBar

Function drawBar

examples/drivers/m5stickc-imu/main.js:120–130  ·  view source on GitHub ↗
(label, value, x, y, width, height)

Source from the content-addressed store, hash-verified

118}
119
120function drawBar(label, value, x, y, width, height) {
121 const halfWidth = width >> 1;
122 const barWidth = (value * halfWidth) | 0;
123
124 if (value > 0)
125 render.fillRectangle(barColor, x + halfWidth, y, barWidth, height);
126 else
127 render.fillRectangle(barColor, x + halfWidth + barWidth, y, -barWidth, height);
128
129 render.drawText(label, font, textColor, x + 50, y);
130}
131
132function moveBallTo(x, y) {
133 const w = ball.width, h = ball.height;

Callers 1

onReadingFunction · 0.70

Calls 2

drawTextMethod · 0.80
fillRectangleMethod · 0.65

Tested by

no test coverage detected