Skip to content

Commit

Permalink
Updated to latest versions of dependencies and fixed bugs resulting f…
Browse files Browse the repository at this point in the history
…rom those updates
  • Loading branch information
Juul committed Dec 13, 2022
1 parent a348b74 commit 1345433
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/fake-canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ module.exports = function createFakeCanvas(w, h) {
y = Math.max(Math.min(y, h), 0)
w_ = Math.max(Math.min(w_, w), 0)
h_ = Math.max(Math.min(h_, h), 0)
var c = Color(this.fillStyle).rgbaArray()
c[3] = (c[3] * 255)|0
var c = Color(this.fillStyle).rgb().array()
c[3] = 255;
var range = pixels.lo(x, y).hi(w_, h_)
for(var i=0; i<4; ++i) {
ops.assigns(range.pick(null, null, i), c[i])
Expand Down
8 changes: 5 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function fprint(buf, len) {


function idhash(str, n, minFill, maxFill) {
var buf = new Buffer(str.length + 1);
var buf = Buffer.alloc(str.length + 1);
buf.write(str);

for (var i=0; i<0x100; i++) {
Expand All @@ -31,10 +31,11 @@ function idhash(str, n, minFill, maxFill) {

var c = [ f.slice(0, 3), f.slice(3, 6)];
c.sort(bright.cmp);
// console.error(fmt("%d < %d < %d", minFill*n, setPixels, maxFill*n));

if (setPixels > (minFill * n) && setPixels < (maxFill * n))

return {
colors: c.map(function (x) { return x.toString('hex'); }),
colors: c.map(function (x) { return Buffer.from(x).toString('hex'); }),
pixels: pixels.value()
};
}
Expand Down Expand Up @@ -72,6 +73,7 @@ function retricon(str, opts) {

var mid = Math.ceil(dimension / 2);
var id = idhash(str, mid * dimension, opts.minFill, opts.maxFill);

var pic = reflect(id, dimension);
var csize = (pixelSize * dimension) + (opts.imagePadding * 2);

Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
"Mikola Lysenko"
],
"dependencies": {
"color": "^0.11.1",
"concat-stream": "^1.5.1",
"lodash": "1.3.x",
"ndarray": "^1.0.18",
"color": "^4.2.3",
"concat-stream": "^2.0.0",
"lodash": "^4.17.21",
"ndarray": "^1.0.19",
"ndarray-ops": "^1.2.2",
"save-pixels": "^2.3.0"
"save-pixels": "^2.3.6"
},
"readmeFilename": "README.md",
"gitHead": "73c998a681b831486c01eea234363798d728ecf2",
Expand Down

0 comments on commit 1345433

Please sign in to comment.