Skip to content

Commit

Permalink
chore: update pixel-getter
Browse files Browse the repository at this point in the history
  • Loading branch information
XadillaX committed Oct 22, 2024
1 parent 373e816 commit 58582ce
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 24 deletions.
9 changes: 2 additions & 7 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[Makefile]
indent_size = 8
indent_style = tab
insert_final_newline = true
max_line_length = 80
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"arrowParens": "avoid"
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"async": "^0.9.0",
"clang-format": "^1.8.0",
"nomnom": "^1.8.1",
"pixel-getter": "^1.0.0",
"spidex": "^2.0.1"
"pixel-getter": "^2.0.1"
},
"scripts": {
"test": "./test/run.js"
Expand Down
39 changes: 24 additions & 15 deletions test/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,17 @@ if (opts.algorithm === 'all') {
async.waterfall(
[
function (callback) {
pixelGetter.get(opts.url, callback, 1, 10000);
pixelGetter.getRaw(opts.url, {
frames: 0,
timeout: 10000,
pixelType: pixelGetter.PixelType.RGB,
}, (err, p) => {
console.error(p.pixels[0].length, p.pixelsCount, p.pixelsCount * 3);
callback(err, p);
})
},
function (pixels, callback) {
pixels = pixels[0];
var buff = Buffer.alloc(3 * pixels.length);
for (var i = 0; i < pixels.length; i++) {
buff[i * 3] = pixels[i].r;
buff[i * 3 + 1] = pixels[i].g;
buff[i * 3 + 2] = pixels[i].b;
}

callback(undefined, buff);
callback(undefined, pixels.pixels[0]);
},
function (buff, callback) {
fs.writeFile(
Expand Down Expand Up @@ -143,11 +142,21 @@ if (opts.algorithm === 'all') {
html += `<img src='${opts.url}' /><br /><br />`;

for (var i = 0; i < result.count; i++) {
html += `<div style='width: 50px; height: 21px; float: left; margin-right: 5px; margin-bottom: 5px; background: #${int32ToRGB(
result.colors[i].color
)}; color: #fff; font-size: 12px; text-align: center; padding-top: 9px;'>${
result.colors[i].count
}</div>`;
html += `<div
style='
width: 50px;
height: 21px;
float: left;
margin-right: 5px;
margin-bottom: 5px;
background: #${int32ToRGB(result.colors[i].color)};
color: #fff;
font-size: 12px;
text-align: center;
padding-top: 9px;
'>
${result.colors[i].count}
</div>`;
}

var filename = `/tmp/${+new Date()}.html`;
Expand Down

0 comments on commit 58582ce

Please sign in to comment.