-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogo.js
More file actions
executable file
·58 lines (50 loc) · 1.26 KB
/
logo.js
File metadata and controls
executable file
·58 lines (50 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const textToImage = require('text-to-image');
const imageDataUri = require('image-data-uri');
const Probability = require('./Probability.js/Probability.js');
const math = require('mathjs');
const fs = require('fs');
function dec2bin(dec) {
return (dec >>> 0).toString(2);
}
function binEncode(data) {
var binArray = []
var datEncode = "";
for (i=0; i < data.length; i++) {
binArray.push(data[i].charCodeAt(0).toString(2));
}
for (j=0; j < binArray.length; j++) {
var pad = padding_left(binArray[j], '0', 8);
datEncode += pad + ' ';
}
function padding_left(s, c, n) { if (! s || ! c || s.length >= n) {
return s;
}
var max = (n - s.length)/c.length;
for (var i = 0; i < max; i++) {
s = c + s; } return s;
}
console.log(binArray);
return binArray;
}
let lines = 32;
let bytesPerLine = 32;
let sumbytes = '';
let byte = 0;
for(let i = 0; i < lines; i++) {
for(let j = 0; j < bytesPerLine; j++) {
sumbytes += dec2bin(byte)
byte++
if(j != bytesPerLine - 1) {
sumbytes += ' ';
}
}
if(i != lines - 1) {
sumbytes += '\n';
}
}
let imageUri = textToImage.generateSync(sumbytes, {
bgColor: "#000000",
textColor: "#FFFFFF",
maxWidth: 3730
});
imageDataUri.outputFile(imageUri, `./logo/1024.png`);