-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoolstest.js
60 lines (47 loc) · 1.62 KB
/
toolstest.js
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
59
60
const test = [
[32, 11, 0xaabbcc, 0xaabbcc, 0xaabbcc, 0xaabbcc, 0xaabbcc, 0],
[32, 11, 0xaabbcc, 0xaabbcc, 0xaabbcc, 0xaabbcc, 0xaabbcc, 0],
[32, 11, 0xaabbcc, 0xaabbcc, 0xaabbcc, 0xaabbcc, 0xaabbcc, 0],
[32, 11, 0xaabbcc, 0xaabbcc, 0xaabbcc, 0xaabbcc, 0xaabbcc, 0],
[32, 11, 0xaabbcc, 0xaabbcc, 0xaabbcc, 0xaabbcc, 0xaabbcc, 0],
[32, 11, 0xaabbcc, 0xaabbcc, 0xaabbcc, 0xaabbcc, 0xaabbcc, 0],
[11, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 32, 0],
[11, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 32, 0],
[11, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 32, 0],
[11, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 32, 0],
[11, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 32, 0],
[11, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 32, 0],
];
const test_pixels = [];
function line_to_pixels(line, dy = 0) {
let currentTag = -1;
let seek_position = 0;
let pixel_position = 0;
while (currentTag != 0) {
currentTag = line[dy][seek_position++];
const count = currentTag >> 1;
const opaque = currentTag & 1;
if (opaque) {
for (var i = 0; i < count; i++) {
test_pixels[dy][pixel_position + i] = line[dy][seek_position + i];
}
seek_position += count;
} else {
for (var i = 0; i < count; i++) {
test_pixels[dy][pixel_position + i] = 0;
}
}
pixel_position += count;
}
}
for (y = 0; y < 12; y++) {
test_pixels.push([]);
for (x = 0; x < 19; x++) {
test_pixels[y].push(0);
}
}
const dy = 7;
line_to_pixels(test, 7);
console.log(test_pixels[dy]);
line_to_pixels(test, 3);
console.log(test_pixels[3]);