* Stroke a blue velocity arrow from `(originX, originY)` along the * body's current velocity vector. Scales by `(hW, hH)` so the arrow * length is visually proportional to the body's size regardless of * scale. Skips the draw entirely (and the counter increment) when * the body is at rest. Used
( renderer, panel, adapter, renderable, originX, originY, hW, hH, )
| 161 | * @param {number} hH |
| 162 | */ |
| 163 | function strokeBodyVelocity( |
| 164 | renderer, |
| 165 | panel, |
| 166 | adapter, |
| 167 | renderable, |
| 168 | originX, |
| 169 | originY, |
| 170 | hW, |
| 171 | hH, |
| 172 | ) { |
| 173 | const v = adapter.getVelocity(renderable, sharedBodyVel); |
| 174 | if (v.x === 0 && v.y === 0) { |
| 175 | return; |
| 176 | } |
| 177 | renderer.save(); |
| 178 | renderer.lineWidth = 1; |
| 179 | renderer.setColor("blue"); |
| 180 | renderer.translate(originX, originY); |
| 181 | renderer.strokeLine(0, 0, Math.trunc(v.x * hW), Math.trunc(v.y * hH)); |
| 182 | panel.counters.inc("velocity"); |
| 183 | renderer.restore(); |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * Monkey-patch melonJS rendering classes to draw debug overlays |
no test coverage detected