MarkTheArtist commited on
Commit
f4909cf
·
verified ·
1 Parent(s): 9c4a1e9

Upload interactive_4x4_line_or_right_angle_only.html

Browse files
interactive_4x4_line_or_right_angle_only.html ADDED
@@ -0,0 +1,426 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>4x4 Line or Right Angle Tile Tool</title>
7
+ <style>
8
+ body {
9
+ margin: 0;
10
+ padding: 22px;
11
+ background: #eee4cf;
12
+ font-family: Arial, Helvetica, sans-serif;
13
+ color: #222;
14
+ }
15
+
16
+ h1 {
17
+ margin: 0 0 8px 0;
18
+ }
19
+
20
+ .notice {
21
+ padding: 12px;
22
+ margin: 12px 0 18px 0;
23
+ border-radius: 10px;
24
+ border: 3px solid #9b2f2f;
25
+ background: #ffe7e7;
26
+ font-weight: bold;
27
+ }
28
+
29
+ .notice.ok {
30
+ border-color: #276c35;
31
+ background: #e5f6e8;
32
+ }
33
+
34
+ .layout {
35
+ display: flex;
36
+ flex-wrap: wrap;
37
+ gap: 22px;
38
+ align-items: flex-start;
39
+ }
40
+
41
+ .panel {
42
+ background: white;
43
+ border: 3px solid #aa9568;
44
+ border-radius: 14px;
45
+ padding: 18px;
46
+ box-shadow: 0 8px 18px rgba(0,0,0,.08);
47
+ }
48
+
49
+ #grid {
50
+ display: grid;
51
+ grid-template-columns: repeat(4, 120px);
52
+ grid-template-rows: repeat(4, 120px);
53
+ gap: 10px;
54
+ background: #b69d6a;
55
+ border: 6px solid #302614;
56
+ padding: 12px;
57
+ max-width: 100%;
58
+ overflow: auto;
59
+ }
60
+
61
+ .cell {
62
+ position: relative;
63
+ width: 120px;
64
+ height: 120px;
65
+ background: #fff8e8;
66
+ border: 4px solid #453720;
67
+ box-sizing: border-box;
68
+ cursor: pointer;
69
+ }
70
+
71
+ .cell.selected {
72
+ outline: 7px solid #ffcc33;
73
+ outline-offset: -9px;
74
+ }
75
+
76
+ .num {
77
+ position: absolute;
78
+ top: 5px;
79
+ left: 7px;
80
+ font-weight: bold;
81
+ color: #7e6c49;
82
+ z-index: 5;
83
+ font-size: 13px;
84
+ }
85
+
86
+ .tile {
87
+ position: absolute;
88
+ left: 14px;
89
+ top: 14px;
90
+ width: 92px;
91
+ height: 92px;
92
+ transform-origin: 46px 46px;
93
+ }
94
+
95
+ /* Design A: one simple thick rectangle/line */
96
+ .line {
97
+ position: absolute;
98
+ left: 5px;
99
+ top: 28px;
100
+ width: 82px;
101
+ height: 36px;
102
+ background: black;
103
+ }
104
+
105
+ /* Design B: one simple thick right angle */
106
+ .angle-v {
107
+ position: absolute;
108
+ left: 28px;
109
+ top: 5px;
110
+ width: 36px;
111
+ height: 46px;
112
+ background: black;
113
+ }
114
+
115
+ .angle-h {
116
+ position: absolute;
117
+ left: 28px;
118
+ top: 28px;
119
+ width: 59px;
120
+ height: 36px;
121
+ background: black;
122
+ }
123
+
124
+ .controls {
125
+ width: 330px;
126
+ max-width: 100%;
127
+ }
128
+
129
+ .group {
130
+ border-bottom: 1px solid #dccba5;
131
+ padding-bottom: 16px;
132
+ margin-bottom: 18px;
133
+ }
134
+
135
+ .group:last-child {
136
+ border-bottom: none;
137
+ }
138
+
139
+ button {
140
+ margin: 5px;
141
+ padding: 11px 13px;
142
+ border: 2px solid #6f5b35;
143
+ border-radius: 8px;
144
+ background: #fff8e8;
145
+ font-weight: bold;
146
+ cursor: pointer;
147
+ font-size: 15px;
148
+ }
149
+
150
+ button:hover {
151
+ background: #ead6aa;
152
+ }
153
+
154
+ button.active {
155
+ background: #ffcc33;
156
+ }
157
+
158
+ #status {
159
+ background: #fff8e8;
160
+ border: 2px solid #d2bd8d;
161
+ border-radius: 8px;
162
+ padding: 10px;
163
+ line-height: 1.45;
164
+ }
165
+
166
+ textarea {
167
+ width: 100%;
168
+ height: 150px;
169
+ font-family: monospace;
170
+ font-size: 12px;
171
+ box-sizing: border-box;
172
+ }
173
+
174
+ .legend {
175
+ display: flex;
176
+ align-items: center;
177
+ gap: 10px;
178
+ margin: 12px 0;
179
+ }
180
+
181
+ .mini {
182
+ position: relative;
183
+ width: 62px;
184
+ height: 62px;
185
+ border: 3px solid #493b23;
186
+ background: #fff8ea;
187
+ overflow: hidden;
188
+ }
189
+
190
+ .mini .line {
191
+ left: 8px;
192
+ top: 22px;
193
+ width: 46px;
194
+ height: 18px;
195
+ }
196
+
197
+ .mini .angle-v {
198
+ left: 22px;
199
+ top: 8px;
200
+ width: 18px;
201
+ height: 24px;
202
+ }
203
+
204
+ .mini .angle-h {
205
+ left: 22px;
206
+ top: 22px;
207
+ width: 32px;
208
+ height: 18px;
209
+ }
210
+
211
+ @media (max-width: 650px) {
212
+ #grid {
213
+ grid-template-columns: repeat(4, 68px);
214
+ grid-template-rows: repeat(4, 68px);
215
+ gap: 6px;
216
+ padding: 7px;
217
+ }
218
+
219
+ .cell {
220
+ width: 68px;
221
+ height: 68px;
222
+ border-width: 3px;
223
+ }
224
+
225
+ .num {
226
+ font-size: 11px;
227
+ top: 3px;
228
+ left: 5px;
229
+ }
230
+
231
+ .tile {
232
+ left: 8px;
233
+ top: 8px;
234
+ width: 52px;
235
+ height: 52px;
236
+ transform-origin: 26px 26px;
237
+ }
238
+
239
+ .line {
240
+ left: 3px;
241
+ top: 16px;
242
+ width: 46px;
243
+ height: 15px;
244
+ }
245
+
246
+ .angle-v {
247
+ left: 16px;
248
+ top: 3px;
249
+ width: 15px;
250
+ height: 26px;
251
+ }
252
+
253
+ .angle-h {
254
+ left: 16px;
255
+ top: 16px;
256
+ width: 33px;
257
+ height: 15px;
258
+ }
259
+ }
260
+ </style>
261
+ </head>
262
+ <body>
263
+
264
+ <h1>4×4 Tile Tool — Line or Right Angle Only</h1>
265
+
266
+ <div id="jsCheck" class="notice">
267
+ JavaScript is NOT running yet. If this message stays here, the file is being opened in a preview mode that blocks interaction.
268
+ </div>
269
+
270
+ <div class="layout">
271
+ <div class="panel">
272
+ <div id="grid"></div>
273
+ </div>
274
+
275
+ <div class="panel controls">
276
+ <div class="group">
277
+ <h2>Selected tile</h2>
278
+ <div id="status">Waiting for JavaScript...</div>
279
+ </div>
280
+
281
+ <div class="group">
282
+ <h2>Design</h2>
283
+ <button id="designA" type="button">Line</button>
284
+ <button id="designB" type="button">Right angle</button>
285
+ </div>
286
+
287
+ <div class="group">
288
+ <h2>Orientation</h2>
289
+ <button class="rot" data-rot="0" type="button">0°</button>
290
+ <button class="rot" data-rot="90" type="button">90°</button>
291
+ <button class="rot" data-rot="180" type="button">180°</button>
292
+ <button class="rot" data-rot="270" type="button">270°</button>
293
+ <br>
294
+ <button id="turn" type="button">Rotate selected 90°</button>
295
+ </div>
296
+
297
+ <div class="group">
298
+ <h2>Legend</h2>
299
+ <div class="legend">
300
+ <div class="mini">
301
+ <div class="line"></div>
302
+ </div>
303
+ <div><b>Line</b><br>one thick rectangle</div>
304
+ </div>
305
+ <div class="legend">
306
+ <div class="mini">
307
+ <div class="angle-v"></div>
308
+ <div class="angle-h"></div>
309
+ </div>
310
+ <div><b>Right angle</b><br>one thick L shape</div>
311
+ </div>
312
+ </div>
313
+
314
+ <div class="group">
315
+ <h2>Layout data</h2>
316
+ <textarea id="dataBox"></textarea>
317
+ <button id="selectData" type="button">Select data</button>
318
+ <button id="reset" type="button">Reset</button>
319
+ </div>
320
+ </div>
321
+ </div>
322
+
323
+ <script>
324
+ (function () {
325
+ var selected = 0;
326
+
327
+ function defaultCells() {
328
+ return [
329
+ {design:"line", rot:0}, {design:"angle", rot:90}, {design:"line", rot:90}, {design:"angle", rot:180},
330
+ {design:"angle", rot:0}, {design:"line", rot:0}, {design:"angle", rot:180},{design:"line", rot:90},
331
+ {design:"line", rot:90}, {design:"angle", rot:270}, {design:"line", rot:0}, {design:"angle", rot:0},
332
+ {design:"angle", rot:270},{design:"line", rot:180}, {design:"angle", rot:90}, {design:"line", rot:0}
333
+ ];
334
+ }
335
+
336
+ var cells = defaultCells();
337
+
338
+ var jsCheck = document.getElementById("jsCheck");
339
+ jsCheck.className = "notice ok";
340
+ jsCheck.textContent = "JavaScript is working. You can click cells and change the design or rotation.";
341
+
342
+ function makeTile(cell) {
343
+ var design = "";
344
+ if (cell.design === "line") {
345
+ design = '<div class="line"></div>';
346
+ } else {
347
+ design = '<div class="angle-v"></div><div class="angle-h"></div>';
348
+ }
349
+ return '<div class="tile" style="transform: rotate(' + cell.rot + 'deg)">' + design + '</div>';
350
+ }
351
+
352
+ function render() {
353
+ var grid = document.getElementById("grid");
354
+ grid.innerHTML = "";
355
+
356
+ for (var i = 0; i < 16; i++) {
357
+ var div = document.createElement("div");
358
+ div.className = "cell" + (i === selected ? " selected" : "");
359
+ div.setAttribute("data-index", i);
360
+ div.innerHTML = '<div class="num">' + (i + 1) + '</div>' + makeTile(cells[i]);
361
+ div.addEventListener("click", function () {
362
+ selected = Number(this.getAttribute("data-index"));
363
+ render();
364
+ });
365
+ grid.appendChild(div);
366
+ }
367
+
368
+ var current = cells[selected];
369
+ var designName = current.design === "line" ? "Line" : "Right angle";
370
+
371
+ document.getElementById("status").innerHTML =
372
+ "Cell " + (selected + 1) + "<br>" + designName + "<br>Rotation " + current.rot + "°";
373
+
374
+ document.getElementById("designA").className = current.design === "line" ? "active" : "";
375
+ document.getElementById("designB").className = current.design === "angle" ? "active" : "";
376
+
377
+ var rotButtons = document.querySelectorAll(".rot");
378
+ for (var r = 0; r < rotButtons.length; r++) {
379
+ var val = Number(rotButtons[r].getAttribute("data-rot"));
380
+ rotButtons[r].className = "rot" + (val === current.rot ? " active" : "");
381
+ }
382
+
383
+ document.getElementById("dataBox").value = JSON.stringify(cells, null, 2);
384
+ }
385
+
386
+ document.getElementById("designA").addEventListener("click", function () {
387
+ cells[selected].design = "line";
388
+ render();
389
+ });
390
+
391
+ document.getElementById("designB").addEventListener("click", function () {
392
+ cells[selected].design = "angle";
393
+ render();
394
+ });
395
+
396
+ var rotButtons = document.querySelectorAll(".rot");
397
+ for (var r = 0; r < rotButtons.length; r++) {
398
+ rotButtons[r].addEventListener("click", function () {
399
+ cells[selected].rot = Number(this.getAttribute("data-rot"));
400
+ render();
401
+ });
402
+ }
403
+
404
+ document.getElementById("turn").addEventListener("click", function () {
405
+ cells[selected].rot = (cells[selected].rot + 90) % 360;
406
+ render();
407
+ });
408
+
409
+ document.getElementById("selectData").addEventListener("click", function () {
410
+ var box = document.getElementById("dataBox");
411
+ box.focus();
412
+ box.select();
413
+ });
414
+
415
+ document.getElementById("reset").addEventListener("click", function () {
416
+ cells = defaultCells();
417
+ selected = 0;
418
+ render();
419
+ });
420
+
421
+ render();
422
+ })();
423
+ </script>
424
+
425
+ </body>
426
+ </html>