-
Notifications
You must be signed in to change notification settings - Fork 0
/
block.html
164 lines (119 loc) · 3.25 KB
/
block.html
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<div id="container"></div>
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
}
.buttons {
position: absolute;
top: 10px;
left: 10px;
}
.buttons button {
border: 1px solid black;
background-color: darkgray;
color: white;
font-size: 16px;
padding: 4px;
}
#time {
font-family: verdana;
font-size: 16px;
font-weight: bold;
}
#pathtime {
font-family: verdana;
font-size: 14px;
font-weight: bold;
color: #cccccc;
}
</style>
<script src="lib/jquery.js"></script>
<script src="lib/socket.io.js"></script>
<script src="lib/three.js"></script>
<script src="lib/helvetiker_regular.typeface.js"></script>
<script src="lib/orbit.js"></script>
<script src="lib/cnclib.js"></script>
<textarea class="buttons" style="display: none">
</textarea>
<script src="lib/qrcode.js"></script>
<script>
var cnc = new cnclib({ z_safe: 0.5, extendCorners: false, defaultSpeed: 150, dipSpeed: 25, stepSizeZ: 1, nPathTrials: 1000, nPathIters: 100 });
var mill = 1;
var depth = 10.1;
var depthqr = 1;
var qrcode = new QRCode(-1, QRErrorCorrectLevel.H);
qrcode.addData("6PRSMZ2ayL2q92tjS1Dr2LVi8wQMYuECn4eHyJGycez3tTpS1vU9ApHmT2");
qrcode.make();
// 6PRSMZ2ayL2q92tjS1Dr2LVi8wQMYuECn4eHyJGycez3tTpS1vU9ApHmT2
var mc = qrcode.getModuleCount();
var width = (mc + 4) * mill;
var height = (mc + 4) * mill;
var border = 4 * mill;
var par = { x: 85/2, y: 27, requires: [] };
//umriss
//cnc.rect({ width: width, height: height, x: width / 2, y: height / 2, inline: true, outlineOnly: true, depth: depthqr * 3, extendCorners: false }, function (par)
//{
var tileW = mill;
var tileH = mill;
for (var j = 0; j < mc; j++)
for (var i = 0; i < mc; i++)
{
if (!qrcode.isDark(i, j))
continue;
var k = i + 1;
for (; k < mc; k++)
{
if (!qrcode.isDark(k, j))
break;
}
var n = k - i;
if (n != 1)
{
var x0 = par.x - (i + 0.5 - mc / 2) * tileW;
var x1 = par.x - (k - 0.5 - mc / 2) * tileW;
var y = par.y - (j + 0.5 - mc / 2) * tileH;
par.requires.push(cnc.line({ points: [ [ (j % 2 == 0) ? x1 : x0, y ], [ (j % 2 == 0) ? x0 : x1, y ] ], depth: depthqr }));
}
i = k - 1;
}
for (var j = 0; j < mc; j++)
for (var i = 0; i < mc; i++)
{
if (!qrcode.isDark(j, i))
continue;
var k = i + 1;
for (; k < mc; k++)
{
if (!qrcode.isDark(j, k))
break;
}
var n = k - i;
if (n != 1)
{
var y0 = par.y - (i + 0.5 - mc / 2) * tileH;
var y1 = par.y - (k - 0.5 - mc / 2) * tileH;
var x = par.x - (j + 0.5 - mc / 2) * tileW;
par.requires.push(cnc.line({ points: [ [ x, j % 2 ? y1 : y0 ], [ x, j % 2 ? y0 : y1 ] ], depth: depthqr }));
}
i = k - 1;
}
for (var j = 0; j < mc; j++)
for (var i = 0; i < mc; i++)
{
if (!qrcode.isDark(i, j))
continue;
if (i < mc - 1 && qrcode.isDark(i + 1, j + 0))
continue;
if (j < mc - 1 && qrcode.isDark(i + 0, j + 1))
continue;
if (i > 1 && qrcode.isDark(i - 1, j + 0))
continue;
if (j > 1 && qrcode.isDark(i + 0, j - 1))
continue;
par.requires.push(cnc.drill({ x: par.x - (i + 0.5 - mc / 2) * tileW, y: par.y - (j + 0.5 - mc / 2) * tileH, depth: depthqr }));
}
// });
$(function() {cnc.done(true)});
</script>