(canvas)
| 25 | } |
| 26 | // Draw x and y axes in the canvas. |
| 27 | function drawAxes(canvas) { |
| 28 | const ctx = canvas.getContext('2d'); |
| 29 | ctx.clearRect(0, 0, canvas.width, canvas.height); |
| 30 | ctx.beginPath(); |
| 31 | const leftCoord = world2canvas(canvas, -canvas.width / 2, 0); |
| 32 | const rightCoord = world2canvas(canvas, canvas.width / 2, 0); |
| 33 | ctx.moveTo(leftCoord[0], leftCoord[1]); |
| 34 | ctx.lineTo(rightCoord[0], rightCoord[1]); |
| 35 | ctx.stroke(); |
| 36 | const topCoord = world2canvas(canvas, 0, canvas.height / 2); |
| 37 | const bottomCoord = world2canvas(canvas, 0, -canvas.height / 2); |
| 38 | ctx.moveTo(topCoord[0], topCoord[1]); |
| 39 | ctx.lineTo(bottomCoord[0], bottomCoord[1]); |
| 40 | ctx.stroke(); |
| 41 | } |
| 42 | |
| 43 | // Draw x and y data in the canvas. |
| 44 | // |
no test coverage detected