📒 Remove worker
This commit is contained in:
parent
a0d614e06d
commit
9e516a7d70
|
@ -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);
|
||||
}());
|
Loading…
Reference in New Issue