function drawTestTriangle(ctx, u1, v1, u2, v2) {
  ctx.beginPath();
  ctx.moveTo(0, 0);
  ctx.lineTo(u1, v1);
  ctx.lineTo(u2, v2);
  ctx.closePath();
  ctx.save();
  ctx.clip();
  ctx.fillRect(0, 0, Math.max(u1, u2) + 1, Math.max(v1, v2));
  ctx.restore();
}
This draws a small triangle into a canvas by setting the triangle as the clip region
and then drawing a (too large) rectangle

@param {CanvasRenderingContext2D} ctx The context in which to draw the triangle
@param {number} u1 The x-coordinate of the second point. The first point is 0,0.
@param {number} v1 The y-coordinate of the second point.
@param {number} u2 The x-coordinate of the third point.
@param {number} v2 The y-coordinate of the third point.