Skip to content
This repository was archived by the owner on Nov 20, 2023. It is now read-only.

Commit 8e1cb81

Browse files
committed
removed unnecessary lines in graphs
1 parent eb1de7f commit 8e1cb81

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

Diff for: scripts/render.js

+16-22
Original file line numberDiff line numberDiff line change
@@ -323,41 +323,35 @@ function renderGraphs() {
323323
// draw the left motor actual velocity graph
324324
leftMotorCtx.strokeStyle = 'red';
325325
for (let i = 0; i <= debugDataTime; i++) {
326-
leftMotorCtx.beginPath();
327-
// get the x and y coordinates
328-
let x0 = 20;
329-
let y0 = 75;
330326
if (i > 0) {
327+
leftMotorCtx.beginPath();
331328
x0 = 20 + ((i-1)/(debugDataList.length-1))*260;
332329
y0 = 75 - (debugDataList[i-1].leftVel/debugData.maxVel)*55;
330+
const x1 = 20 + (i/(debugDataList.length-1))*260;
331+
const y1 = 75 - (debugDataList[i].leftVel/debugData.maxVel)*55;
332+
leftMotorCtx.moveTo(x0, y0);
333+
leftMotorCtx.lineTo(x1, y1);
334+
// draw the line
335+
leftMotorCtx.stroke();
336+
leftMotorCtx.closePath();
333337
}
334-
const x1 = 20 + (i/(debugDataList.length-1))*260;
335-
const y1 = 75 - (debugDataList[i].leftVel/debugData.maxVel)*55;
336-
leftMotorCtx.moveTo(x0, y0);
337-
leftMotorCtx.lineTo(x1, y1);
338-
// draw the line
339-
leftMotorCtx.stroke();
340-
leftMotorCtx.closePath();
341338
}
342339

343340
// draw the left motor target velocity graph
344341
leftMotorCtx.strokeStyle = 'blue';
345342
for (let i = 0; i <= debugDataTime; i++) {
346-
leftMotorCtx.beginPath();
347-
// get the x and y coordinates
348-
let x0 = 20;
349-
let y0 = 75;
350343
if (i > 0) {
344+
leftMotorCtx.beginPath();
351345
x0 = 20 + ((i-1)/(debugDataList.length-1))*260;
352346
y0 = 75 - (debugDataList[i-1].leftTargetVel/debugData.maxVel)*55;
347+
const x1 = 20 + (i/(debugDataList.length-1))*260;
348+
const y1 = 75 - (debugDataList[i].leftTargetVel/debugData.maxVel)*55;
349+
leftMotorCtx.moveTo(x0, y0);
350+
leftMotorCtx.lineTo(x1, y1);
351+
// draw the line
352+
leftMotorCtx.stroke();
353+
leftMotorCtx.closePath();
353354
}
354-
const x1 = 20 + (i/(debugDataList.length-1))*260;
355-
const y1 = 75 - (debugDataList[i].leftTargetVel/debugData.maxVel)*55;
356-
leftMotorCtx.moveTo(x0, y0);
357-
leftMotorCtx.lineTo(x1, y1);
358-
// draw the line
359-
leftMotorCtx.stroke();
360-
leftMotorCtx.closePath();
361355
}
362356

363357
// reset right motor canvas

0 commit comments

Comments
 (0)