commit d76faefdec423b742089b72a976b8f0f7bc6f7f1
Author: Hardwell99 <3022256519@qq.com>
Date: Wed Nov 18 11:34:55 2026 +0800
Initial commit
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..dfe0770
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+# Auto detect text files and perform LF normalization
+* text=auto
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..7d05e99
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,10 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# 依赖于环境的 Maven 主目录路径
+/mavenHomeManager.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/PhotoWall.iml b/.idea/PhotoWall.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/.idea/PhotoWall.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..07115cd
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..e58c7c4
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/img/1793460679986.png b/assets/img/1793460679986.png
new file mode 100644
index 0000000..eae9216
Binary files /dev/null and b/assets/img/1793460679986.png differ
diff --git a/assets/img/1793460702468.png b/assets/img/1793460702468.png
new file mode 100644
index 0000000..64de53c
Binary files /dev/null and b/assets/img/1793460702468.png differ
diff --git a/assets/img/1793460705640.png b/assets/img/1793460705640.png
new file mode 100644
index 0000000..1186eb8
Binary files /dev/null and b/assets/img/1793460705640.png differ
diff --git a/assets/img/1794318085822.png b/assets/img/1794318085822.png
new file mode 100644
index 0000000..878c2b4
Binary files /dev/null and b/assets/img/1794318085822.png differ
diff --git a/assets/img/1794486619061.png b/assets/img/1794486619061.png
new file mode 100644
index 0000000..1347893
Binary files /dev/null and b/assets/img/1794486619061.png differ
diff --git a/assets/img/1794652590020.png b/assets/img/1794652590020.png
new file mode 100644
index 0000000..20728da
Binary files /dev/null and b/assets/img/1794652590020.png differ
diff --git a/assets/img/RDT_20261114_1838401112059065207923484.jpg b/assets/img/RDT_20261114_1838401112059065207923484.jpg
new file mode 100644
index 0000000..aa9e8c3
Binary files /dev/null and b/assets/img/RDT_20261114_1838401112059065207923484.jpg differ
diff --git a/assets/img/RDT_20261114_1839092334126551755891923.jpg b/assets/img/RDT_20261114_1839092334126551755891923.jpg
new file mode 100644
index 0000000..36ec1b6
Binary files /dev/null and b/assets/img/RDT_20261114_1839092334126551755891923.jpg differ
diff --git a/assets/img/RDT_20261114_1839131355937088287474941.jpg b/assets/img/RDT_20261114_1839131355937088287474941.jpg
new file mode 100644
index 0000000..eeca247
Binary files /dev/null and b/assets/img/RDT_20261114_1839131355937088287474941.jpg differ
diff --git a/assets/img/Screenshot_2026-10-31-15-31-53-652_com.instagram.android-edit.jpg b/assets/img/Screenshot_2026-10-31-15-31-53-652_com.instagram.android-edit.jpg
new file mode 100644
index 0000000..9755dea
Binary files /dev/null and b/assets/img/Screenshot_2026-10-31-15-31-53-652_com.instagram.android-edit.jpg differ
diff --git a/assets/img/VOSR2_upscaled_x2_HW_VVskbYAE60Oo_20261117_212857.png b/assets/img/VOSR2_upscaled_x2_HW_VVskbYAE60Oo_20261117_212857.png
new file mode 100644
index 0000000..96c9a86
Binary files /dev/null and b/assets/img/VOSR2_upscaled_x2_HW_VVskbYAE60Oo_20261117_212857.png differ
diff --git a/assets/img/VOSR2_upscaled_x2_RDT_20261114_1838498_20261117_214156.png b/assets/img/VOSR2_upscaled_x2_RDT_20261114_1838498_20261117_214156.png
new file mode 100644
index 0000000..aef5422
Binary files /dev/null and b/assets/img/VOSR2_upscaled_x2_RDT_20261114_1838498_20261117_214156.png differ
diff --git a/assets/img/image_1789474692962.jpg b/assets/img/image_1789474692962.jpg
new file mode 100644
index 0000000..9895247
Binary files /dev/null and b/assets/img/image_1789474692962.jpg differ
diff --git a/assets/img/image_1793273216172.jpg b/assets/img/image_1793273216172.jpg
new file mode 100644
index 0000000..265892e
Binary files /dev/null and b/assets/img/image_1793273216172.jpg differ
diff --git a/assets/img/image_1793460850677.jpg b/assets/img/image_1793460850677.jpg
new file mode 100644
index 0000000..c6bdde4
Binary files /dev/null and b/assets/img/image_1793460850677.jpg differ
diff --git a/assets/img/image_1793460854504.jpg b/assets/img/image_1793460854504.jpg
new file mode 100644
index 0000000..9baa297
Binary files /dev/null and b/assets/img/image_1793460854504.jpg differ
diff --git a/assets/img/image_1793460860160.jpg b/assets/img/image_1793460860160.jpg
new file mode 100644
index 0000000..72cb067
Binary files /dev/null and b/assets/img/image_1793460860160.jpg differ
diff --git a/assets/img/img-1793460564813ce290ec99e90ba59d011a45738b8e829879d3c5d20f9c3373ff293030596368a.jpg b/assets/img/img-1793460564813ce290ec99e90ba59d011a45738b8e829879d3c5d20f9c3373ff293030596368a.jpg
new file mode 100644
index 0000000..7d188b8
Binary files /dev/null and b/assets/img/img-1793460564813ce290ec99e90ba59d011a45738b8e829879d3c5d20f9c3373ff293030596368a.jpg differ
diff --git a/assets/img/img-1793575563154a3625c1720ceff524ccbcc280bb700fcb6ee741d06c59a9d487681e3b12b0ed3.jpg b/assets/img/img-1793575563154a3625c1720ceff524ccbcc280bb700fcb6ee741d06c59a9d487681e3b12b0ed3.jpg
new file mode 100644
index 0000000..5141e19
Binary files /dev/null and b/assets/img/img-1793575563154a3625c1720ceff524ccbcc280bb700fcb6ee741d06c59a9d487681e3b12b0ed3.jpg differ
diff --git a/assets/img/img-17935755718269e7e33eea3cacdffae9f9da3cdc3ebb08d1c83fffc1193f1024a40f729b51d72.jpg b/assets/img/img-17935755718269e7e33eea3cacdffae9f9da3cdc3ebb08d1c83fffc1193f1024a40f729b51d72.jpg
new file mode 100644
index 0000000..b57f1ca
Binary files /dev/null and b/assets/img/img-17935755718269e7e33eea3cacdffae9f9da3cdc3ebb08d1c83fffc1193f1024a40f729b51d72.jpg differ
diff --git a/assets/img/img-1794745267039cfe0e8f8044ee103ee9b30c4f41e6379e231a92370e3e019a4b8dce437f407da.jpg b/assets/img/img-1794745267039cfe0e8f8044ee103ee9b30c4f41e6379e231a92370e3e019a4b8dce437f407da.jpg
new file mode 100644
index 0000000..4bab585
Binary files /dev/null and b/assets/img/img-1794745267039cfe0e8f8044ee103ee9b30c4f41e6379e231a92370e3e019a4b8dce437f407da.jpg differ
diff --git a/assets/img/img-179474527214730822a98d45864300ce2876ecd1d830cc1c0687c3ee72efcf9fe999778eb50ce.jpg b/assets/img/img-179474527214730822a98d45864300ce2876ecd1d830cc1c0687c3ee72efcf9fe999778eb50ce.jpg
new file mode 100644
index 0000000..6f89c51
Binary files /dev/null and b/assets/img/img-179474527214730822a98d45864300ce2876ecd1d830cc1c0687c3ee72efcf9fe999778eb50ce.jpg differ
diff --git a/assets/img/img-17947452752440da437582648d25fa580a418dcf366bf4f59231e32ef3e24415d8e10a21331cf.jpg b/assets/img/img-17947452752440da437582648d25fa580a418dcf366bf4f59231e32ef3e24415d8e10a21331cf.jpg
new file mode 100644
index 0000000..ceef8d9
Binary files /dev/null and b/assets/img/img-17947452752440da437582648d25fa580a418dcf366bf4f59231e32ef3e24415d8e10a21331cf.jpg differ
diff --git a/assets/img/img-1794745278168db2fb63c6e0e9579bd2dc0023c94cb545052c1baa9f990fe79c878efcb318887.jpg b/assets/img/img-1794745278168db2fb63c6e0e9579bd2dc0023c94cb545052c1baa9f990fe79c878efcb318887.jpg
new file mode 100644
index 0000000..9d7083b
Binary files /dev/null and b/assets/img/img-1794745278168db2fb63c6e0e9579bd2dc0023c94cb545052c1baa9f990fe79c878efcb318887.jpg differ
diff --git a/assets/img/img-1794745281556231db3fd028ffd3483bd3bf91300ce3bb29e16422b9591c9e5501887ef3c71c5.jpg b/assets/img/img-1794745281556231db3fd028ffd3483bd3bf91300ce3bb29e16422b9591c9e5501887ef3c71c5.jpg
new file mode 100644
index 0000000..e1b2be8
Binary files /dev/null and b/assets/img/img-1794745281556231db3fd028ffd3483bd3bf91300ce3bb29e16422b9591c9e5501887ef3c71c5.jpg differ
diff --git a/assets/img/img-1794745285566ad8729dd6d8841e909e23641109f8e36ed09668611b2b892215acd02e5e847da.jpg b/assets/img/img-1794745285566ad8729dd6d8841e909e23641109f8e36ed09668611b2b892215acd02e5e847da.jpg
new file mode 100644
index 0000000..dd82a8a
Binary files /dev/null and b/assets/img/img-1794745285566ad8729dd6d8841e909e23641109f8e36ed09668611b2b892215acd02e5e847da.jpg differ
diff --git a/assets/img/img-1794745288755ae4f540d0fa3c96bcf2bb25db03094b4836704a966d0a62a5ca2e54ef256fe78.jpg b/assets/img/img-1794745288755ae4f540d0fa3c96bcf2bb25db03094b4836704a966d0a62a5ca2e54ef256fe78.jpg
new file mode 100644
index 0000000..a447d2e
Binary files /dev/null and b/assets/img/img-1794745288755ae4f540d0fa3c96bcf2bb25db03094b4836704a966d0a62a5ca2e54ef256fe78.jpg differ
diff --git a/assets/img/img-1794745292259e749051d21f787b82b6e3e53ffd7d87b6269b915283c75856cda0743acc2754d.jpg b/assets/img/img-1794745292259e749051d21f787b82b6e3e53ffd7d87b6269b915283c75856cda0743acc2754d.jpg
new file mode 100644
index 0000000..22cad2c
Binary files /dev/null and b/assets/img/img-1794745292259e749051d21f787b82b6e3e53ffd7d87b6269b915283c75856cda0743acc2754d.jpg differ
diff --git a/assets/img/img-1794745295723a2950baa20b0526046c3ffdab740bd231c89fd740ebed464a0305605ff93b86a.jpg b/assets/img/img-1794745295723a2950baa20b0526046c3ffdab740bd231c89fd740ebed464a0305605ff93b86a.jpg
new file mode 100644
index 0000000..8e83997
Binary files /dev/null and b/assets/img/img-1794745295723a2950baa20b0526046c3ffdab740bd231c89fd740ebed464a0305605ff93b86a.jpg differ
diff --git a/assets/img/img-1794745307856d2147457d0c9917d6369b4620d7e7d18b83ba2cee8439b3300c64c4aee64bb52.jpg b/assets/img/img-1794745307856d2147457d0c9917d6369b4620d7e7d18b83ba2cee8439b3300c64c4aee64bb52.jpg
new file mode 100644
index 0000000..3e922f6
Binary files /dev/null and b/assets/img/img-1794745307856d2147457d0c9917d6369b4620d7e7d18b83ba2cee8439b3300c64c4aee64bb52.jpg differ
diff --git a/index.pen.html b/index.pen.html
new file mode 100644
index 0000000..a5085b5
--- /dev/null
+++ b/index.pen.html
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+ Scattered Polaroids — CSS random()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/script.js b/script.js
new file mode 100644
index 0000000..6e144a3
--- /dev/null
+++ b/script.js
@@ -0,0 +1,348 @@
+(() => {
+ "use strict";
+ /* PHOTOS:START */
+ const photos = [
+ { src: "assets/img/1793460679986.png" },
+ { src: "assets/img/1793460702468.png" },
+ { src: "assets/img/1793460705640.png" },
+ { src: "assets/img/1794318085822.png" },
+ { src: "assets/img/1794486619061.png" },
+ { src: "assets/img/1794652590020.png" },
+ { src: "assets/img/image_1789474692962.jpg" },
+ { src: "assets/img/image_1793273216172.jpg" },
+ { src: "assets/img/image_1793460850677.jpg" },
+ { src: "assets/img/image_1793460854504.jpg" },
+ { src: "assets/img/image_1793460860160.jpg" },
+ { src: "assets/img/img-1793460564813ce290ec99e90ba59d011a45738b8e829879d3c5d20f9c3373ff293030596368a.jpg" },
+ { src: "assets/img/img-1793575563154a3625c1720ceff524ccbcc280bb700fcb6ee741d06c59a9d487681e3b12b0ed3.jpg" },
+ { src: "assets/img/img-17935755718269e7e33eea3cacdffae9f9da3cdc3ebb08d1c83fffc1193f1024a40f729b51d72.jpg" },
+ { src: "assets/img/img-1794745267039cfe0e8f8044ee103ee9b30c4f41e6379e231a92370e3e019a4b8dce437f407da.jpg" },
+ { src: "assets/img/img-179474527214730822a98d45864300ce2876ecd1d830cc1c0687c3ee72efcf9fe999778eb50ce.jpg" },
+ { src: "assets/img/img-17947452752440da437582648d25fa580a418dcf366bf4f59231e32ef3e24415d8e10a21331cf.jpg" },
+ { src: "assets/img/img-1794745278168db2fb63c6e0e9579bd2dc0023c94cb545052c1baa9f990fe79c878efcb318887.jpg" },
+ { src: "assets/img/img-1794745281556231db3fd028ffd3483bd3bf91300ce3bb29e16422b9591c9e5501887ef3c71c5.jpg" },
+ { src: "assets/img/img-1794745285566ad8729dd6d8841e909e23641109f8e36ed09668611b2b892215acd02e5e847da.jpg" },
+ { src: "assets/img/img-1794745288755ae4f540d0fa3c96bcf2bb25db03094b4836704a966d0a62a5ca2e54ef256fe78.jpg" },
+ { src: "assets/img/img-1794745292259e749051d21f787b82b6e3e53ffd7d87b6269b915283c75856cda0743acc2754d.jpg" },
+ { src: "assets/img/img-1794745295723a2950baa20b0526046c3ffdab740bd231c89fd740ebed464a0305605ff93b86a.jpg" },
+ { src: "assets/img/img-1794745307856d2147457d0c9917d6369b4620d7e7d18b83ba2cee8439b3300c64c4aee64bb52.jpg" },
+ { src: "assets/img/RDT_20261114_1838401112059065207923484.jpg" },
+ { src: "assets/img/RDT_20261114_1839092334126551755891923.jpg" },
+ { src: "assets/img/RDT_20261114_1839131355937088287474941.jpg" },
+ { src: "assets/img/Screenshot_2026-10-31-15-31-53-652_com.instagram.android-edit.jpg" },
+ { src: "assets/img/VOSR2_upscaled_x2_HW_VVskbYAE60Oo_20261117_212857.png" },
+ { src: "assets/img/VOSR2_upscaled_x2_RDT_20261114_1838498_20261117_214156.png" }
+ ];
+ /* PHOTOS:END */
+
+ const scene = document.getElementById("scene");
+ const shuffleBtn = document.getElementById("shuffleBtn");
+ if (!scene) return;
+ const supportsRandom = CSS.supports("width", "random(1px, 10px)");
+ if (!supportsRandom) {
+ document.body.classList.add("no-random")
+ }
+ const MARGIN = 6;
+ const MAX_TRIES = 400;
+ const OVERLAP_RATIO = 0.35;
+ const promoted = new Map();
+ let topZ = 1000;
+
+ function promote(card) {
+ const z = ++topZ;
+ card.style.zIndex = z;
+ if (card.dataset.src) promoted.set(card.dataset.src, z)
+ }
+ const STANDARDS = [{
+ label: "4 / 3",
+ value: 4 / 3
+ }, {
+ label: "3 / 4",
+ value: 3 / 4
+ }, {
+ label: "1 / 1",
+ value: 1
+ }];
+
+ function pickStandard(w, h) {
+ const r = w / h;
+ return STANDARDS.reduce((best, s) => Math.abs(Math.log(r / s.value)) < Math.abs(Math.log(r / best.value)) ? s : best)
+ }
+
+ function loadImage(src) {
+ return new Promise((resolve, reject) => {
+ const img = new Image();
+ img.onload = () => resolve(img);
+ img.onerror = () => reject(new Error(`Failed to load: ${src}`));
+ img.src = src
+ })
+ }
+
+ function rand(min, max) {
+ return Math.random() * (max - min) + min
+ }
+
+ function intersectionArea(a, b) {
+ const w = Math.min(a.right, b.right) - Math.max(a.left, b.left);
+ const h = Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top);
+ if (w <= 0 || h <= 0) return 0;
+ return w * h
+ }
+
+ function overlaps(a, b, margin) {
+ const bExpanded = {
+ left: b.left - margin,
+ top: b.top - margin,
+ right: b.right + margin,
+ bottom: b.bottom + margin
+ };
+ const inter = intersectionArea(a, bExpanded);
+ if (inter === 0) return !1;
+ const areaA = (a.right - a.left) * (a.bottom - a.top);
+ const areaB = (bExpanded.right - bExpanded.left) * (bExpanded.bottom - bExpanded.top);
+ const ratioA = inter / areaA;
+ const ratioB = inter / areaB;
+ return ratioA > OVERLAP_RATIO || ratioB > OVERLAP_RATIO
+ }
+
+ function findFreePosition(w, h, placed, vw, vh) {
+ const minX = 10;
+ const maxX = Math.max(minX, vw - w - 10);
+ const minY = 70;
+ const maxY = Math.max(minY, vh - h - 10);
+ for (let i = 0; i < MAX_TRIES; i++) {
+ const x = rand(minX, maxX);
+ const y = rand(minY, maxY);
+ const rect = {
+ left: x,
+ top: y,
+ right: x + w,
+ bottom: y + h
+ };
+ const collides = placed.some(p => overlaps(rect, p, MARGIN));
+ if (!collides) return rect
+ }
+ return null
+ }
+
+ function build() {
+ scene.innerHTML = "";
+ const vw = window.innerWidth;
+ const vh = window.innerHeight;
+ const root = getComputedStyle(document.documentElement);
+ const imgW = parseFloat(root.getPropertyValue("--img-w"));
+ const frameX = 16;
+ const frameY = 46;
+ const placed = [];
+ let skipped = 0;
+ const shuffled = [...photos].sort(() => Math.random() - 0.5);
+ shuffled.forEach((photo) => {
+ const std = pickStandard(photo.width, photo.height);
+ const imgH = Math.round(imgW / std.value);
+ const cardW = imgW + frameX;
+ const cardH = imgH + frameY;
+ const rect = findFreePosition(cardW, cardH, placed, vw, vh);
+ if (!rect) {
+ skipped++;
+ return
+ }
+ placed.push(rect);
+ const name = photo.src.split("/").pop();
+ const card = document.createElement("figure");
+ card.className = "polaroid";
+ card.dataset.src = photo.src;
+ card.tabIndex = 0;
+ card.setAttribute("role", "img");
+ card.setAttribute("aria-label", `Polaroid: ${name}`);
+ const promotedZ = promoted.get(photo.src);
+ if (promotedZ) {
+ card.style.zIndex = promotedZ;
+ topZ = Math.max(topZ, promotedZ)
+ }
+ card.style.setProperty("--x", `${rect.left}px`);
+ card.style.setProperty("--y", `${rect.top}px`);
+ card.style.setProperty("--card-w", `${cardW}px`);
+ card.style.setProperty("--card-h", `${cardH}px`);
+ if (!supportsRandom) {
+ card.style.setProperty("--fallback-angle", `${rand(-14, 14)}deg`)
+ }
+ const img = document.createElement("img");
+ img.src = photo.src;
+ img.alt = name;
+ img.loading = "lazy";
+ img.style.aspectRatio = std.label;
+ img.onerror = () => {
+ card.remove()
+ };
+ card.append(img);
+ scene.appendChild(card)
+ });
+ if (skipped > 0) {
+ console.info(`[polaroids] ${skipped} card(s) not placed due to lack of space.`)
+ }
+ }
+ Promise.all(photos.map(photo => loadImage(photo.src).then(img => {
+ photo.width = img.naturalWidth;
+ photo.height = img.naturalHeight;
+ return photo
+ }).catch(() => null))).then(list => {
+ const loaded = list.filter(Boolean);
+ photos.length = 0;
+ photos.push(...loaded);
+ build()
+ });
+ let dragState = null;
+ const KEEP_VISIBLE = 40;
+
+ scene.addEventListener("pointerover", (e) => {
+ const card = e.target.closest(".polaroid");
+ if (!card || card.contains(e.relatedTarget)) return;
+ promote(card)
+ });
+
+ scene.addEventListener("focusin", (e) => {
+ const card = e.target.closest(".polaroid");
+ if (card) promote(card)
+ });
+
+ scene.addEventListener("pointerdown", (e) => {
+ const card = e.target.closest(".polaroid");
+ if (!card || (e.button !== undefined && e.button !== 0)) return;
+ e.preventDefault();
+ const startX = parseFloat(card.style.getPropertyValue("--x")) || 0;
+ const startY = parseFloat(card.style.getPropertyValue("--y")) || 0;
+ dragState = {
+ card,
+ pointerId: e.pointerId,
+ offsetX: e.clientX - startX,
+ offsetY: e.clientY - startY
+ };
+ card.classList.add("dragging");
+ promote(card);
+ try {
+ card.setPointerCapture(e.pointerId)
+ } catch (_) {}
+ });
+
+ scene.addEventListener("pointermove", (e) => {
+ if (!dragState || e.pointerId !== dragState.pointerId) return;
+ const { card, offsetX, offsetY } = dragState;
+ const cw = card.offsetWidth;
+ const ch = card.offsetHeight;
+ const vw = window.innerWidth;
+ const vh = window.innerHeight;
+ let nx = e.clientX - offsetX;
+ let ny = e.clientY - offsetY;
+ nx = Math.min(Math.max(nx, -(cw - KEEP_VISIBLE)), vw - KEEP_VISIBLE);
+ ny = Math.min(Math.max(ny, -(ch - KEEP_VISIBLE)), vh - KEEP_VISIBLE);
+ card.style.setProperty("--x", `${nx}px`);
+ card.style.setProperty("--y", `${ny}px`)
+ });
+
+ function endDrag(e) {
+ if (!dragState || e.pointerId !== dragState.pointerId) return;
+ const { card } = dragState;
+ card.classList.remove("dragging");
+ try {
+ card.releasePointerCapture(e.pointerId)
+ } catch (_) {}
+ dragState = null
+ }
+ scene.addEventListener("pointerup", endDrag);
+ scene.addEventListener("pointercancel", endDrag);
+
+ let resizeTimer;
+ window.addEventListener("resize", () => {
+ clearTimeout(resizeTimer);
+ resizeTimer = setTimeout(build, 200)
+ });
+ if (shuffleBtn) {
+ shuffleBtn.addEventListener("click", () => {
+ promoted.clear();
+ build()
+ })
+ }
+
+ const THEMES = {
+ violet: { label: "Violet 紫罗兰", a: "#8357eb", b: "#6a3de0", c: "#a86ff5" },
+ space: { label: "Space 深空", a: "#0d0b1e", b: "#1b1440", c: "#2a1d52" },
+ teal: { label: "Teal 青碧", a: "#062a30", b: "#0a3d40", c: "#0e5560" },
+ sand: { label: "Sand 沙色", a: "#f3e2c7", b: "#f7d9a8", c: "#e8b98a" },
+ black: { label: "Black 墨黑", a: "#050507", b: "#101018", c: "#16161f" }
+ };
+ const THEME_KEY = "photowall-bg";
+ const settingsBtn = document.getElementById("settingsBtn");
+ const settingsPanel = document.getElementById("settingsPanel");
+ const settingsClose = document.getElementById("settingsClose");
+ const themeList = document.getElementById("themeList");
+
+ function applyTheme(key) {
+ const t = THEMES[key];
+ if (!t) return;
+ const rs = document.documentElement.style;
+ rs.setProperty("--bg-a", t.a);
+ rs.setProperty("--bg-b", t.b);
+ rs.setProperty("--bg-c", t.c);
+ try {
+ localStorage.setItem(THEME_KEY, key)
+ } catch (_) {}
+ if (themeList) {
+ themeList.querySelectorAll(".theme-option").forEach(btn => {
+ btn.setAttribute("aria-checked", String(btn.dataset.theme === key))
+ })
+ }
+ }
+
+ if (themeList) {
+ Object.entries(THEMES).forEach(([key, t]) => {
+ const btn = document.createElement("button");
+ btn.type = "button";
+ btn.className = "theme-option";
+ btn.dataset.theme = key;
+ btn.setAttribute("role", "radio");
+ btn.setAttribute("aria-checked", "false");
+ const dot = document.createElement("span");
+ dot.className = "dot";
+ const label = document.createElement("span");
+ label.className = "label";
+ label.textContent = t.label;
+ const swatch = document.createElement("span");
+ swatch.className = "swatch";
+ [t.a, t.b, t.c].forEach(color => {
+ const i = document.createElement("i");
+ i.style.background = color;
+ swatch.appendChild(i)
+ });
+ btn.append(dot, label, swatch);
+ btn.addEventListener("click", () => applyTheme(key));
+ themeList.appendChild(btn)
+ });
+ let saved = null;
+ try {
+ saved = localStorage.getItem(THEME_KEY)
+ } catch (_) {}
+ applyTheme(THEMES[saved] ? saved : "violet")
+ }
+
+ function setPanel(open) {
+ if (!settingsPanel || !settingsBtn) return;
+ settingsPanel.classList.toggle("open", open);
+ settingsBtn.setAttribute("aria-expanded", String(open))
+ }
+ if (settingsBtn && settingsPanel) {
+ settingsBtn.addEventListener("click", () => {
+ setPanel(!settingsPanel.classList.contains("open"))
+ });
+ if (settingsClose) {
+ settingsClose.addEventListener("click", () => setPanel(false))
+ }
+ document.addEventListener("pointerdown", (e) => {
+ if (!settingsPanel.classList.contains("open")) return;
+ if (settingsPanel.contains(e.target) || settingsBtn.contains(e.target)) return;
+ setPanel(false)
+ });
+ document.addEventListener("keydown", (e) => {
+ if (e.key === "Escape") setPanel(false)
+ })
+ }
+})()
\ No newline at end of file
diff --git a/style.css b/style.css
new file mode 100644
index 0000000..a09dd03
--- /dev/null
+++ b/style.css
@@ -0,0 +1,316 @@
+*,
+*::before,
+*::after {
+ box-sizing: border-box;
+ margin: 0;
+ padding: 0
+}
+
+html,
+body {
+ width: 100%;
+ height: 100%;
+ overflow: hidden
+}
+
+:root {
+ --table-bg: #2b2118;
+ --table-bg-2: #3a2d22;
+ --polaroid-bg: #faf8f3;
+ --img-w: 244px;
+ --bg-a: #8357eb;
+ --bg-b: #6a3de0;
+ --bg-c: #a86ff5
+}
+
+body {
+ font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
+ background: radial-gradient(circle at 25% 15%, var(--bg-a), transparent 55%), radial-gradient(circle at 80% 85%, var(--bg-b), transparent 50%), var(--bg-c);
+ position: relative;
+ isolation: isolate
+}
+
+body::before {
+ content: "";
+ position: fixed;
+ inset: 0;
+ pointer-events: none;
+ background: repeating-linear-gradient(92deg, rgb(0 0 0 / .07) 0 2px, transparent 2px 9px), repeating-linear-gradient(2deg, rgb(255 255 255 / .015) 0 1px, transparent 1px 40px);
+ z-index: 0
+}
+
+.scene {
+ position: fixed;
+ inset: 0;
+ z-index: 1
+}
+
+.polaroid {
+ position: absolute;
+ width: var(--card-w, calc(var(--img-w) + 16px));
+ padding: 8px 8px 38px;
+ background: var(--polaroid-bg);
+ border-radius: 4px;
+ cursor: grab;
+ touch-action: none;
+ user-select: none;
+ -webkit-user-select: none;
+ transition: transform 0.5s cubic-bezier(.22, 1, .36, 1), box-shadow 0.5s ease, filter 0.4s ease;
+ will-change: transform;
+ transform-origin: center center;
+ top: var(--y, 20px);
+ left: var(--x, 20px);
+ --jitter-x: random(-10px, 10px);
+ --jitter-y: random(-10px, 10px);
+ --angle: random(-14deg, 14deg);
+ --shadow-x: random(-6px, 6px);
+ --shadow-y: random(5px, 14px);
+ --shadow-blur: random(10px, 22px);
+ transform: translate(var(--jitter-x), var(--jitter-y)) rotate(var(--angle));
+ box-shadow: 0 1px 1px rgb(0 0 0 / .15), var(--shadow-x) var(--shadow-y) var(--shadow-blur) rgb(0 0 0 / .4)
+}
+
+.polaroid img {
+ display: block;
+ width: 100%;
+ aspect-ratio: 1 / 1;
+ object-fit: contain;
+ object-position: center;
+ background: var(--polaroid-bg);
+ border-radius: 2px;
+ pointer-events: none
+}
+
+.polaroid:hover,
+.polaroid:focus-visible {
+ transform: translate(0, -6px) rotate(0deg) scale(1.08);
+ box-shadow: 0 2px 2px rgb(0 0 0 / .2), 0 22px 44px rgb(0 0 0 / .55);
+ outline: none;
+ filter: brightness(1.03)
+}
+
+.polaroid:focus-visible {
+ outline: 2px solid #e8c07a;
+ outline-offset: 4px
+}
+
+.no-random .polaroid {
+ --jitter-x: 0px;
+ --jitter-y: 0px;
+ --angle: var(--fallback-angle, 0deg);
+ --shadow-x: 0px;
+ --shadow-y: 8px;
+ --shadow-blur: 14px
+}
+
+.polaroid.dragging,
+.polaroid.dragging:hover,
+.polaroid.dragging:focus-visible {
+ cursor: grabbing;
+ transition: none;
+ transform: translate(0, 0) rotate(var(--angle)) scale(1.06);
+ box-shadow: 0 2px 2px rgb(0 0 0 / .2), 0 26px 50px rgb(0 0 0 / .6);
+ filter: brightness(1.05);
+ outline: none
+}
+
+.fab {
+ position: fixed;
+ right: 14px;
+ transform: translateY(-50%);
+ width: 36px;
+ height: 36px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border: 1px solid rgb(255 255 255 / .18);
+ border-radius: 50%;
+ background: rgb(0 0 0 / .25);
+ color: rgb(255 255 255 / .75);
+ cursor: pointer;
+ opacity: .35;
+ z-index: 1000;
+ backdrop-filter: blur(4px);
+ transition: opacity .3s ease, background .3s ease
+}
+
+.fab:hover,
+.fab:focus-visible {
+ opacity: 1;
+ background: rgb(0 0 0 / .55);
+ outline: none
+}
+
+.fab:active {
+ transform: translateY(-50%) scale(.92)
+}
+
+.fab svg {
+ transition: transform .5s ease
+}
+
+.shuffle-btn {
+ top: 50%
+}
+
+.shuffle-btn:hover svg {
+ transform: rotate(180deg)
+}
+
+.settings-btn {
+ top: calc(50% + 46px)
+}
+
+.settings-btn:hover svg,
+.settings-btn[aria-expanded="true"] svg {
+ transform: rotate(90deg)
+}
+
+.settings-panel {
+ position: fixed;
+ right: 62px;
+ top: 50%;
+ transform: translateY(-50%) translateX(10px);
+ width: 236px;
+ padding: 14px;
+ border-radius: 16px;
+ background: rgb(10 10 16 / .82);
+ border: 1px solid rgb(255 255 255 / .12);
+ backdrop-filter: blur(12px);
+ box-shadow: 0 18px 44px rgb(0 0 0 / .45);
+ color: #f3e9d2;
+ z-index: 1001;
+ opacity: 0;
+ visibility: hidden;
+ pointer-events: none;
+ transition: opacity .25s ease, transform .25s ease, visibility .25s
+}
+
+.settings-panel.open {
+ opacity: 1;
+ visibility: visible;
+ pointer-events: auto;
+ transform: translateY(-50%) translateX(0)
+}
+
+.settings-head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ margin-bottom: 12px;
+ font-size: 12px;
+ letter-spacing: .14em;
+ color: rgb(243 233 210 / .8)
+}
+
+.settings-close {
+ all: unset;
+ cursor: pointer;
+ width: 22px;
+ height: 22px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border-radius: 50%;
+ font-size: 14px;
+ line-height: 1;
+ color: rgb(243 233 210 / .6);
+ transition: background .2s ease, color .2s ease
+}
+
+.settings-close:hover,
+.settings-close:focus-visible {
+ background: rgb(255 255 255 / .12);
+ color: #fff;
+ outline: none
+}
+
+.theme-list {
+ display: flex;
+ flex-direction: column;
+ gap: 8px
+}
+
+.theme-option {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ width: 100%;
+ padding: 9px 14px;
+ border-radius: 999px;
+ border: 1px solid rgb(255 255 255 / .14);
+ background: rgb(255 255 255 / .06);
+ color: rgb(255 255 255 / .55);
+ font-family: inherit;
+ font-size: 13px;
+ cursor: pointer;
+ transition: background .25s ease, color .25s ease, box-shadow .25s ease, border-color .25s ease
+}
+
+.theme-option:hover,
+.theme-option:focus-visible {
+ background: rgb(255 255 255 / .12);
+ color: rgb(255 255 255 / .85);
+ outline: none
+}
+
+.theme-option .dot {
+ position: relative;
+ flex: none;
+ width: 16px;
+ height: 16px;
+ border-radius: 50%;
+ border: 2px solid currentColor
+}
+
+.theme-option .dot::after {
+ content: "";
+ position: absolute;
+ inset: 3px;
+ border-radius: 50%;
+ background: currentColor;
+ transform: scale(0);
+ transition: transform .2s ease
+}
+
+.theme-option .label {
+ flex: 1;
+ text-align: left;
+ letter-spacing: .04em
+}
+
+.theme-option .swatch {
+ display: flex;
+ gap: 3px
+}
+
+.theme-option .swatch i {
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ border: 1px solid rgb(0 0 0 / .25)
+}
+
+.theme-option[aria-checked="true"] {
+ background: #3ddc97;
+ border-color: transparent;
+ color: #06281c;
+ font-weight: 600;
+ box-shadow: 0 0 18px rgb(61 220 151 / .45)
+}
+
+.theme-option[aria-checked="true"] .dot::after {
+ transform: scale(1)
+}
+
+@media (max-width:900px) {
+ :root {
+ --img-w: 114px
+ }
+}
+
+@media (max-width:600px) {
+ :root {
+ --img-w: 89px
+ }
+}
\ No newline at end of file
diff --git a/update-photos.bat b/update-photos.bat
new file mode 100644
index 0000000..459de9c
--- /dev/null
+++ b/update-photos.bat
@@ -0,0 +1,46 @@
+@echo off
+rem ============================================================
+rem Update photos in script.js
+rem Scans assets/img for images and rewrites the photos array
+rem between /* PHOTOS:START */ and /* PHOTOS:END */ markers.
+rem ============================================================
+setlocal
+cd /d "%~dp0"
+
+if not exist "assets\img" (
+ echo [ERROR] assets\img folder not found.
+ pause
+ exit /b 1
+)
+if not exist "script.js" (
+ echo [ERROR] script.js not found.
+ pause
+ exit /b 1
+)
+
+powershell -NoProfile -ExecutionPolicy Bypass -Command ^
+ "$ErrorActionPreference='Stop';" ^
+ "$exts='.jpg','.jpeg','.png','.gif','.webp','.bmp','.avif';" ^
+ "$files=@(Get-ChildItem -LiteralPath 'assets/img' -File | Where-Object { $exts -contains $_.Extension.ToLower() } | Sort-Object Name);" ^
+ "if ($files.Count -eq 0) { Write-Host '[ERROR] No images found in assets/img'; exit 1 };" ^
+ "$q=[char]34;" ^
+ "$entries=@($files | ForEach-Object { ' { src: ' + $q + 'assets/img/' + $_.Name + $q + ' }' });" ^
+ "$nl=[Environment]::NewLine;" ^
+ "$block='/* PHOTOS:START */' + $nl + ' const photos = [' + $nl + ($entries -join (',' + $nl)) + $nl + ' ];' + $nl + ' /* PHOTOS:END */';" ^
+ "$content=Get-Content -LiteralPath 'script.js' -Raw -Encoding UTF8;" ^
+ "if ($content -notmatch 'PHOTOS:START') { Write-Host '[ERROR] PHOTOS markers not found in script.js'; exit 1 };" ^
+ "$pattern='(?s)/\* PHOTOS:START \*/.*?/\* PHOTOS:END \*/';" ^
+ "$new=[regex]::Replace($content, $pattern, $block.Replace('$','$$'));" ^
+ "[System.IO.File]::WriteAllText((Resolve-Path 'script.js').Path, $new, (New-Object System.Text.UTF8Encoding($false)));" ^
+ "Write-Host ('[OK] ' + $files.Count + ' image(s) written to script.js:');" ^
+ "$files | ForEach-Object { Write-Host (' - ' + $_.Name) }"
+
+if errorlevel 1 (
+ echo.
+ echo Update failed.
+ pause
+ exit /b 1
+)
+
+echo.
+pause
\ No newline at end of file