You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
643 B
JavaScript

'use strict';
module.exports = function drawDebugLine(context, lineNumber, y, width, color = "red") {
context.strokeStyle = color;
context.beginPath();
if (typeof width === "number") {
context.moveTo(0, y);
context.lineTo(width, y);
} else {
context.moveTo(width[0], y);
context.lineTo(width[1], y);
}
context.stroke();
let boxOffsets = ["red", "green", "blue", "orange"];
let boxOffset = boxOffsets.indexOf(color);
context.fillStyle = color;
context.fillRect(boxOffset * 18, y + 3, 16, 16);
context.font = "12px sans-serif";
context.fillStyle = "white";
context.fillText(lineNumber, 5 + boxOffset * 18, y + 15);
};