📒 Remove worker

This commit is contained in:
Mattéo Delabre 2015-12-16 23:04:34 +01:00
parent a0d614e06d
commit 9e516a7d70
1 changed files with 0 additions and 38 deletions

View File

@ -1,38 +0,0 @@
/*jslint plusplus: true */
/*globals self, importScripts, utils */
(function () {
'use strict';
importScripts('utils.js');
function getRandomPoint(w, h) {
return [utils.getRandomArbitary(0, 1) * w, utils.getRandomArbitary(0, 1) * h];
}
self.addEventListener('message', function (e) {
var points = [], vertices = e.data[2], size = e.data[1], point, pointSkip = 100,
i = parseInt(e.data[0], 10) + pointSkip, j, length = vertices.length,
frac = e.data[3], cvert, numvertex, correction;
correction = 1 / frac - 1; // make points fit in the container
point = getRandomPoint(size[0], size[1]);
do {
numvertex = utils.getRandomInt(0, vertices.length - 1);
cvert = vertices[numvertex];
point = [(cvert[0] + point[0]) * (frac), (cvert[1] + point[1]) * (frac)];
if (i > pointSkip) { // skip the first few points
points.push([
[
point[0] * correction,
point[1] * correction
], numvertex
]);
}
} while (i--);
self.postMessage(points);
}, false);
}());