MCPcopy Index your code
hub / github.com/tensorflow/tfjs-examples / drawAxes

Function drawAxes

polynomial-regression/index.js:27–41  ·  view source on GitHub ↗
(canvas)

Source from the content-addressed store, hash-verified

25}
26// Draw x and y axes in the canvas.
27function 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//

Callers 1

drawXYDataFunction · 0.85

Calls 1

world2canvasFunction · 0.85

Tested by

no test coverage detected