slow Delaunay triangulation

by Darby Rathbone

HTML

<canvas></canvas>

CSS

* {
    margin:0px;
    padding:0px;
}
html, body {
    height:100%;
    overflow:hidden;
}
canvas {
    width:100%;
    height:100%;
    outline:black 1px solid;
}

JavaScript

var rect = function (e, t) {
    var n = document.createElement("canvas");
    n.c = n.getContext("2d");
    n.width = canvas.width;
    n.height = canvas.height;
    return function (r) {
        n.c.clearRect(0, 0, n.width, n.height);
        n.c.strokeRect(t.x * 2, t.y * 2, r.x * 2 - t.x * 2, r.y * 2 - t.y * 2);
        e();
        ctx.drawImage(n, 0, 0);
        return rect
    }
}, line = function (e, t) {
    var n = document.createElement("canvas");
    n.c = n.getContext("2d");
    n.width = canvas.width;
    n.height = canvas.height;
    return function (t) {
        n.c.clearRect(0, 0, n.width, n.height);
        e();
        ctx.drawImage(n, 0, 0);
        return line
    }
}, bufferd = document.createElement("canvas");
bufferd.width = screen.width * 2;
bufferd.height = screen.height * 2;

var buffer = function () {

    t = bufferd.getContext("2d");

    t.drawImage(ctx.canvas, 0, 0);

    var n = function () {
        ctx.clearRect(0, 0, bufferd.width, bufferd.height);
        ctx.drawImage(bufferd, 0, 0)
    };

    return n
}, resizeFunction = function (e) {
    var t = buffer();
    canvas.width = parseFloat(getComputedStyle(canvas).width) * 2;
    canvas.height = parseFloat(getComputedStyle(canvas).height) * 2;
    if (e) {
        t()
    }
}, mousemovefunction = function (e) {
    //currentfunction(newPoint(e.x, e.y))

}, mouseupfunction = function (e) {
    //  currentfunction = currentfunction(newPoint(e.x, e.y));

    // points.push(newPoint(e.x * 2, e.y * 2));
    //  drawpoints();
    //  delaunay();

    window.removeEventListener("mousemove", mousemovefunction);
    window.removeEventListener("mouseup", mouseupfunction)
}, mousedownfunction = function (e) {
    var t = buffer(),
        _point = newPoint(e.x * 2, e.y * 2);
    if (!points.some(function (b) {
        var d = Math.sqrt((b.x - _point.x) * (b.x - _point.x) + (b.y - _point.y) * (b.y - _point.y));
        return d < 10;
    })) {
        points.push(_point);

        //...