/**
* 根据给定的坐标和颜色绘制一条直线
* @param {CanvasRenderingContext2D} ctx - 渲染上下文.
* @param {number} fx - 起点横坐标.
* @param {number} fy - 起点纵坐标.
* @param {number} tx - 终点横坐标.
* @param {number} ty - 终点纵坐标.
* @param {string} color - 颜色.
*/
function drawLine(ctx, fx, fy, tx, ty, color) {
ctx.fillStyle = color;
ctx.translate(fx, fy);
ctx.rotate(Math.atan2(ty - fy, tx - fx));
ctx.fillRect(0, 0, Math.sqrt(Math.pow(tx - fx, 2) + Math.pow(ty - fy, 2)), 1);
ctx.setTransform(1, 0, 0, 1, 0, 0);
}