-
Notifications
You must be signed in to change notification settings - Fork 0
/
somePrintingStuff.js
64 lines (64 loc) · 1.53 KB
/
somePrintingStuff.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
61
62
63
64
function makeFrame(a, b, c, d, theme){
var T=13;
for (var i=a+T; i<=c-T; i++)
{
setPixel(i, b, theme[1]);
setPixel(i, d, theme[1]);
}
for (var i=b+T; i<=d-T; i++)
{
setPixel(a, i, theme[1]);
setPixel(c, i, theme[1]);
}
var corner=[
[3, 9, 2, 3, 4, 5, 9, 5, 4, 3, 2, 1],
[9, 9, 1],
[2, 1, 0, 1, 2, 9, 1, 2, 3, 9, 4, 5],
[3, 9, 1, 9, 3],
[4, 9, 2, 3, 4, 9, 4, 5],
[5],
[9, 9, 1, 9, 4],
[5, 9, 2, 9, 5],
[4, 9, 3],
[3],
[2, 9, 4],
[1, 9, 5]
];
for (var i=0; i<corner.length; i++)
for (var j=0; j<corner[i].length; j++)
if (corner[i][j]!=9)
{
setPixel(a+i, b+j, theme[corner[i][j]]);
setPixel(a+i, d-j, theme[corner[i][j]]);
setPixel(c-i, b+j, theme[corner[i][j]]);
setPixel(c-i, d-j, theme[corner[i][j]]);
}
}
function printText(x, y, text, scale, color, ALPH){
var XX=x, YY=y, last=[];
for (var c of text)
{
if (c==' ')
{
y+=scale*4;
continue;
}
var T;
if ('a'.charCodeAt()<=c.charCodeAt() && c.charCodeAt()<='z'.charCodeAt())
T=ALPH[c.charCodeAt()-'a'.charCodeAt()];
if ('0'.charCodeAt()<=c.charCodeAt() && c.charCodeAt()<='9'.charCodeAt())
T=ALPH[c.charCodeAt()-'0'.charCodeAt()+26];
for (var i=0; i<T.length; i++)
for (var j=0; j<T[i].length; j++)
if (T[i][j]==1)
for (var ii=0; ii<scale; ii++)
for (var jj=0; jj<scale; jj++)
{
setPixel(x+i*scale+ii, y+j*scale+jj, color);
last[0]=x+i*scale+ii;
last[1]=y+j*scale+jj;
}
y+=scale*T[0].length+scale;
}
return {a: XX, b: YY, c: last[0], d: last[1]};
}