window.onload = function() { var canvas = document.getElementById("draw-area"); var ctx = canvas.getContext("2d"); var points = [new Point(100, 400), new Point(200, 100), new Point(400, 150)]; createStroke(ctx, points); }; function createStroke(ctx, points) { ctx.moveTo(points[0].x, points[0].y); for(var i = 1; i < points.length; i++) { ctx.lineTo(points[i].x, points[i].y); } ctx.stroke(); } class Point { constructor(x, y) { this.x = x; this.y = y; } }