From 04a0e1a9120e96d4174c9f0aacbcfff8c754d27d Mon Sep 17 00:00:00 2001 From: Pierre Date: Mon, 30 Mar 2026 12:22:56 +0200 Subject: [PATCH] Print grid on html + minimalist css (which will not be used) --- web/assets/css/index.css | 117 ++++++++++++++++++++++++++++++++++ web/assets/js/index.js | 79 +++++++++++++++++++++++ web/templates/view/index.html | 14 ++++ 3 files changed, 210 insertions(+) diff --git a/web/assets/css/index.css b/web/assets/css/index.css index e69de29..1244a0a 100644 --- a/web/assets/css/index.css +++ b/web/assets/css/index.css @@ -0,0 +1,117 @@ +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +html, body { + width: 100%; + height: 100%; + overflow: hidden; +} + +body { + background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); + display: flex; + align-items: center; + justify-content: center; + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; +} + +main { + display: flex; + align-items: center; + justify-content: center; + padding: 20px; + border-radius: 15px; + background: rgba(255, 255, 255, 0.1); + backdrop-filter: blur(4px); + min-width: fit-content; + flex-shrink: 0; +} + +.map { + display: flex; + flex-direction: column; + gap: 2px; + padding: 15px; + background: rgba(0, 0, 0, 0.2); + border-radius: 10px; + width: fit-content; + height: fit-content; +} + +.lign { + display: flex; + margin: 2px 2px; +} + +.cell { + border: 2px solid rgba(255, 255, 255, 0.3); + border-radius: 5px; + width: 100%; + height: 100%; + transition: all 0.2s ease; + display: flex; + align-items: center; + justify-content: center; + margin: 2px 2px; +} + +.empty { + background-color: rgba(200, 200, 200, 0.3); +} + +.empty:hover { + background-color: rgba(200, 200, 200, 0.5); +} + +.laser { + background-color: #FFD700; + border-color: #FFA500; +} + +.colored-laser { + background: linear-gradient(45deg, #FF1493, #00CED1); + box-shadow: inset 0 0 10px rgba(255, 20, 147, 0.6); + border-color: #FF1493; +} + +.mirror { + background: linear-gradient(45deg, #C0C0C0 25%, transparent 25%, transparent 75%, #C0C0C0 75%) / 10px 10px; + background-color: #E8E8E8; + border-color: #A9A9A9; +} + +.door { + background-color: #8B4513; + border-color: #654321; + position: relative; +} + +.door::after { + content: '🚪'; + font-size: 24px; +} + +.button { + background-color: #FF6347; + border-color: #DC143C; + border-radius: 50%; +} + +.wall { + background-color: #2F4F4F; + border-color: #000000; + box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8); +} + +.demi-wall { + background: linear-gradient(to right, #2F4F4F 50%, rgba(200, 200, 200, 0.3) 50%); + border-color: #444444; +} + +.target { + background: radial-gradient(circle, #00FF00 30%, rgba(0, 255, 0, 0.3) 70%); + border-color: #00CC00; +} \ No newline at end of file diff --git a/web/assets/js/index.js b/web/assets/js/index.js index e69de29..7122392 100644 --- a/web/assets/js/index.js +++ b/web/assets/js/index.js @@ -0,0 +1,79 @@ +// Legend of grid case + +const legend = { + empty: 0, + laser: 1, + coloredLaser: 2, + mirror: 3, + door:4, + button: 5, + wall: 6, + demiWall: 7, + target: 8, +} + +// Grid test + +let grid = [ + [0, 0, 0, 0, 0, 0, 0, 0], + [0, 1, 0, 0, 0, 0, 0, 0], + [0, 0, 3, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 8, 0], + [0, 0, 0, 0, 0, 0, 0, 0], +] + +// Function to print grid + +function loadGrid () { + const mapDiv = document.getElementById("map"); // Div with map in DOM + mapDiv.innerHTML = ""; + + for (let y = 0; y < grid.length; y++) { + const lign = document.createElement("div"); + lign.classList.add("lign"); + + for (let x = 0; x < grid[y].length; x++) { + const cell = document.createElement("div"); + cell.classList.add("cell"); + + switch (grid[y][x]) { + case legend.empty: + cell.classList.add("empty"); + break; + case legend.laser: + cell.classList.add("laser"); + break; + case legend.coloredLaser: + cell.classList.add("colored-laser"); + break; + case legend.mirror: + cell.classList.add("mirror"); + break; + case legend.door: + cell.classList.add("door"); + break; + case legend.button: + cell.classList.add("button"); + break; + case legend.wall: + cell.classList.add("wall"); + break; + case legend.demiWall: + cell.classList.add("demi-wall"); + break; + case legend.target: + cell.classList.add("target"); + break; + } + + lign.appendChild(cell); + } + + mapDiv.appendChild(lign); + } +} + +loadGrid(); \ No newline at end of file diff --git a/web/templates/view/index.html b/web/templates/view/index.html index e69de29..a99f86b 100644 --- a/web/templates/view/index.html +++ b/web/templates/view/index.html @@ -0,0 +1,14 @@ + + + + + + + Index + + +
+ + + + \ No newline at end of file