Drawing Line connections not smooth on Offline Page
The offline page displayed allows users to draw anything on the screen, presumably while they wait to get access to the internet again. (The landing page when the user tries connecting to the website without an internet connection (or with one which doesn't work). The lines drawn are not smooth since they are simply connected by lines through the vertices.
A simple algorithm can be used to make these vertex connections smooth (quadratic curves). Included below is a very simple implementation of this from one of my own projects.
The code in your project uses firstX and secondX to draw lines, which works but is not the most elegant solution. You could store in memory temporarily all the vertices of the current path and draw them with this algorithm. If this is not clear, I will be pleased to make amends to the original file and make a pull request. For context this uses the needlessjs library to handle the canvas, which can easily be substituted with vanilla code.
drawPoints = (points = [[9,9],[4,3],[45,56]]) => {
const ctx = this.currentCtx;
if (points.length === 1) {
ctx.fillStyle = ctx.strokeStyle;
this.noStroke();
return this.circle(points[0][0], points[0][1], ctx.lineWidth / 2);
} else if (points.length === 0) return;
ctx.beginPath();
// ctx.setLineDash([5, 15]);
ctx.moveTo(points[0][0], points[0][1]);
if (points.length < 3) {
for (let point of points) {
ctx.lineTo(point[0], point[1]);
}
ctx.stroke();
return
}
let i;
// draw a bunch of quadratics, using the average of two points as the control point
for (i = 1; i < points.length - 2; i++) {
var c = (points[i][0] + points[i + 1][0]) / 2,
d = (points[i][1] + points[i + 1][1]) / 2;
ctx.quadraticCurveTo(points[i][0], points[i][1], c, d);
}
ctx.quadraticCurveTo(points[i][0], points[i][1], points[i + 1][0], points[i + 1][1]);
ctx.stroke();
ctx.closePath();
}
Current:

Suggested:

@umerkk164 thanks for the issue! we don't want any external dependencies for the offline page, so we'd want to inline the library if we used it.
is needlessjs open source and if so, what license is it under?