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