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

Function moveBallTo

examples/drivers/lis3dhball/main.js:109–126  ·  view source on GitHub ↗
(x, y)

Source from the content-addressed store, hash-verified

107}
108
109function moveBallTo(x, y) {
110 const w = ball.width, h = ball.height;
111
112 if ((Math.abs(ball.x - x) <= w) && (Math.abs(ball.y - y) <= h))
113 render.begin(Math.min(ball.x, x), Math.min(ball.y, y), w << 1, h << 1); // often overdrawing
114 else {
115 render.begin(ball.x, ball.y, w, h);
116 render.fillRectangle(ball.backgroundColor, 0, 0, width, height);
117 render.continue(x, y, w, h);
118 }
119
120 render.fillRectangle(ball.backgroundColor, 0, 0, width, height);
121 render.drawMasked(ball, x, y, 0, 0, w, h, ball.alpha, 0, 0);
122 render.end();
123
124 ball.x = x;
125 ball.y = y;
126}

Callers 1

main.jsFile · 0.70

Calls 5

drawMaskedMethod · 0.80
beginMethod · 0.65
fillRectangleMethod · 0.65
continueMethod · 0.65
endMethod · 0.65

Tested by

no test coverage detected