aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/schedule.js2
-rw-r--r--utils/raster.js2
-rw-r--r--utils/vec.js3
3 files changed, 5 insertions, 2 deletions
diff --git a/tools/schedule.js b/tools/schedule.js
index d8509b8..b18f5e8 100644
--- a/tools/schedule.js
+++ b/tools/schedule.js
@@ -86,7 +86,7 @@ exports.Queue = function(delayms, maxExport, call){
// Step 2: Start at lowest, and pop all until job.data.length>job.normweight*num (decreasing num as popping and recalc job.normweight). Delete the job.
let weightsum = jobq.map(job => job.wt).reduce((acc, cur)=>acc+cur);
- while (jobq[0] && jobq[0].data.length<(jobq[0].wacc+jobq[0].wt*num/weightsum)){
+ while (jobq[0] && jobq[0].data.length<(jobq[0].wt*num/weightsum)){
weightsum -= jobq[0].wt;
dequeued.push(...jobq.shift().data);
}
diff --git a/utils/raster.js b/utils/raster.js
index 44f4678..1e17838 100644
--- a/utils/raster.js
+++ b/utils/raster.js
@@ -6,7 +6,7 @@ const vec = require('./vec');
module.exports = function(space){
// just use .subsection
let tiles = {};
- dim = ms(space).map(coord => vec.dot(coord,[1/8, 1/16])).map(tile => vec.elem(tile, [], a => Math.floor(a)));
+ dim = ms(space).map(coord => vec.charToTile(coord));
for (let y=dim[0][0]; y<=dim[0][1]; y++) for (let x=dim[1][0]; x<=dim[1][1]; x++){
let tile = tileToChar([y,x]);
tiles[tile] = space.subsection(tile, vec.add(tile, [8,16]));
diff --git a/utils/vec.js b/utils/vec.js
index d595989..57104df 100644
--- a/utils/vec.js
+++ b/utils/vec.js
@@ -33,6 +33,9 @@ exports.dot = function(orig,vec){
exports.tileToChar = function(orig){
return exports.dot(orig, [8,16]);
}
+exports.charToTile = function(orig){
+ return exports.elem(exports.dot(orig, [1/8, 1/16]), [], a => Math.floor(a));
+}
exports.norm = function(orig){
let sum = orig.reduce( (acc, cur) => acc+cur );
return exports.dot(orig, 1/sum);