commit 053cdd39345e0f33a55db9fa4813367982cf1d0a Author: hermes Date: Wed Dec 2 13:19:59 2026 +0000 Built site for Pages diff --git a/.env b/.env new file mode 100644 index 0000000..e8054b7 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +# The address of the published site, for the og: tags. No secrets here: this file is committed. +VITE_SITE_URL=https://pages.obahan.xyz/lullu/advent-of-slop-02-ugly-sweater diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3bdd52e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules/ +dist/ +.DS_Store diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..63f87c2 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +26.12.1 diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..4877420 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,53 @@ +# My Advent of AI Slop entry + +One small web page, made for one day of [Advent of AI Slop](https://advent-of-slop.quesma.com) (1 to 24 December +2026). The task of each day is behind its door there. One repository per day, named +`advent-of-slop--`, for example `advent-of-slop-01-living-fishtank`. + +## What is here + +- `index.html` and `src/main.ts`: the page. +- `src/badge.ts`: the label in the top right corner, "Advent of AI Slop [Day 1] Living fishtank", which links to the + calendar and to the day. +- `public/preview.png`: the picture shown when the link is shared. +- `.github/workflows/pages.yml`: publishes the page on GitHub Pages after every push to `main`. + +## Building it + +What the page does and how it looks is free: any library, any framework, any style. Add packages with pnpm. + +Keep these in `index.html`: + +- `<title>`, the description and the `og:` tags, rewritten for what was built. +- `<advent-badge day="N" name="...">` with the day this is for and the title of that day, and the script that loads + `src/badge.ts`. + +Replace `public/preview.png` with a 1200 by 630 screenshot of the finished page. + +The page is served from `https://<login>.github.io/<repository>/`, so: + +- Links and file paths are relative (`./`), never starting with `/`. +- There is no server. Everything runs in the browser, and anything in the page, API keys included, is public. + +## Commands + +```sh +pnpm install +pnpm dev # http://localhost:5173/ +pnpm build # typecheck and build to dist/; must pass before a push +``` + +## Publishing + +Push to `main`. A minute later the page is at `https://<login>.github.io/<repository>/`. + +Once per repository, GitHub Pages has to take its site from GitHub Actions (Settings > Pages > Source), or: + +```sh +gh api -X POST "repos/{owner}/{repo}/pages" -f build_type=workflow +``` + +A push made before that fails in the "Publish" workflow: run it again (`gh run rerun --failed`). + +To be listed on the calendar, the repository is public and belongs to the person's own account, not an +organization. They submit the address of the page and of the repository on the day's page. diff --git a/README.md b/README.md new file mode 100644 index 0000000..a9ba4e6 --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# My Advent of AI Slop entry + +A template for [Advent of AI Slop](https://advent-of-slop.quesma.com): one small web page a day, 1 to 24 December +2026, built with any AI tool and published on your own GitHub Pages. One copy of this template per day. + +1. **Use this template** (the green button above) to make your own copy. Owner: you. Visibility: public. Name: the + one shown behind the day's door, such as `advent-of-slop-01-living-fishtank`. +2. Switch on publishing, as below. +3. Tell your coding agent what you want to build, and give it the instructions shown next to the day's idea. + +## Publishing + +Every push to `main` publishes the page at `https://<you>.github.io/<repository>/`. GitHub needs it switched on +once per repository: + +- **Settings > Pages > Source: GitHub Actions** +- or, with the GitHub CLI: `gh api -X POST "repos/{owner}/{repo}/pages" -f build_type=workflow` + +If a "Publish" run failed before that, open it in the **Actions** tab and press **Re-run all jobs**. + +## More + +Step by step, from no GitHub account at all: [how to start](https://advent-of-slop.quesma.com/start/). + +It is Vite and TypeScript with pnpm, and a workflow that publishes every push to `main`. What you build is yours +to choose. Details for you and your agent: [AGENTS.md](AGENTS.md). + +```sh +pnpm install +pnpm dev # http://localhost:5173/ +pnpm build +``` diff --git a/assets/index-3yrm8t_j.css b/assets/index-3yrm8t_j.css new file mode 100644 index 0000000..e91c692 --- /dev/null +++ b/assets/index-3yrm8t_j.css @@ -0,0 +1 @@ +:root{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--bg:#14181f;--card:#1d232e;--line:#2c3542;--text:#e8e2d5;--dim:#9aa4b2;--accent:#e0b64f}*{box-sizing:border-box}body{background:radial-gradient(1200px 600px at 70% -10%, #1f2a3a 0%, transparent 60%), var(--bg);min-height:100vh;color:var(--text);margin:0;font:15px/1.5 system-ui,-apple-system,Segoe UI,sans-serif}.wrap{max-width:1150px;margin:0 auto;padding:.9rem 1.25rem 1rem}header h1{letter-spacing:.01em;margin:0;font-size:1.55rem}header .sub{color:var(--dim);margin:.15rem 0 0;font-size:.9rem}.layout{align-items:flex-start;gap:1.25rem;margin-top:.8rem;display:flex}.stage{background:radial-gradient(420px 320px at 50% 42%, #e0b64f17, transparent 70%), var(--card);border:1px solid var(--line);border-radius:14px;flex:auto;justify-content:center;align-items:center;min-height:480px;padding:.75rem;display:flex}canvas{filter:drop-shadow(0 10px 24px #00000073);max-width:100%;height:auto;max-height:70vh}.panel{flex-direction:column;flex:0 0 320px;gap:.7rem;display:flex}.name-card{background:var(--card);border:1px solid var(--line);border-radius:14px;padding:.75rem .9rem}.sweater-name{color:var(--accent);min-height:1.4em;font-size:1.15rem;font-weight:700}.meter-row{align-items:center;gap:.5rem;margin-top:.45rem;display:flex}.meter-label{text-transform:uppercase;letter-spacing:.08em;color:var(--dim);white-space:nowrap;font-size:.72rem}.meter{background:#0e1218;border-radius:6px;flex:1;height:10px;overflow:hidden}.meter-fill{border-radius:6px;width:0;height:100%;transition:width .35s}.meter-score{font-variant-numeric:tabular-nums;text-align:right;min-width:2.2em;font-weight:700}.meter-verdict{color:var(--dim);margin-top:.3rem;font-size:.85rem;font-style:italic}.palette-line{color:var(--dim);margin-top:.45rem;font-size:.8rem}.controls{background:var(--card);border:1px solid var(--line);border-radius:14px;flex-direction:column;gap:.55rem;padding:.75rem .9rem;display:flex}button{font:inherit;color:#1a1408;cursor:pointer;background:linear-gradient(#f0c964,#d9a83e);border:0;border-radius:9px;padding:.45rem .9rem;font-weight:600}button:hover{filter:brightness(1.08)}button.big{padding:.6rem .9rem;font-size:1rem}button:not(.big){color:var(--text);background:#2c3542}.ctl{color:var(--dim);flex-direction:column;gap:.25rem;font-size:.82rem;display:flex}.ctl b{color:var(--text)}input[type=range]{accent-color:var(--accent)}select,input[type=number]{font:inherit;color:var(--text);border:1px solid var(--line);background:#0e1218;border-radius:8px;padding:.35rem .55rem}.seed-row{gap:.4rem;display:flex}.seed-row input{flex:1;min-width:0}.seed-row button{padding:.4rem .6rem}.hint{color:var(--dim);margin:0;font-size:.75rem}@media (width<=860px){.layout{flex-direction:column}.panel{flex:auto;width:100%}} diff --git a/assets/index-B3N9nPYb.js b/assets/index-B3N9nPYb.js new file mode 100644 index 0000000..c3da005 --- /dev/null +++ b/assets/index-B3N9nPYb.js @@ -0,0 +1,68 @@ +(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=`https://advent-of-slop.quesma.com`,t=` + nav { + position: fixed; + top: 0; + right: 0; + z-index: 2147483647; + display: flex; + flex-wrap: wrap; + gap: 0 0.35em; + max-width: 100vw; + box-sizing: border-box; + padding: 0.35rem 0.7rem; + border-bottom-left-radius: 0.5rem; + background: #b8232f; + font: 700 0.8125rem/1.2 system-ui, sans-serif; + } + a { + color: #f6ecd6; + text-decoration: none; + } + a:hover { + text-decoration: underline; + } +`,n=(e,t)=>{let n=document.createElement(`a`);return n.href=e,n.textContent=t,n},r=class extends HTMLElement{connectedCallback(){let r=Number(this.getAttribute(`day`));if(!Number.isInteger(r)||r<1||r>24)throw Error(`<advent-badge> needs day="1" to day="24", got ${this.getAttribute(`day`)}`);let i=this.getAttribute(`name`);if(i===null||i.trim()===``)throw Error(`<advent-badge> needs name="...", the title of its day, such as name="Living fishtank"`);let a=document.createElement(`style`);a.textContent=t;let o=document.createElement(`nav`);o.append(n(`${e}/`,`Advent of AI Slop`),n(`${e}/day/${r}/`,`[Day ${r}] ${i}`)),this.attachShadow({mode:`open`}).append(a,o)}};customElements.define(`advent-badge`,r);var i=[{name:`Sleigh Crash`,clash:70,body:`#b3121f`,colors:[`#1e7d32`,`#f4c430`,`#ffffff`,`#ff5fa2`]},{name:`Eggnog Nightmare`,clash:85,body:`#f3e3b8`,colors:[`#39d353`,`#ff2f92`,`#ff7b00`,`#26c6da`]},{name:`Radioactive Pine`,clash:92,body:`#2fbf3f`,colors:[`#7b2ff7`,`#ff1744`,`#ffe600`,`#00e5ff`]},{name:`Tinsel Overload`,clash:65,body:`#1c1c1c`,colors:[`#ffd700`,`#e91e63`,`#00bcd4`,`#ff5252`]},{name:`Grinch Sick`,clash:75,body:`#43a047`,colors:[`#f06292`,`#ba68c8`,`#ffee58`,`#4fc3f7`]},{name:`Candy Cane Vomit`,clash:80,body:`#ff8fa3`,colors:[`#d90429`,`#ffffff`,`#80ed99`,`#ffd60a`]},{name:`Nordic Normie`,clash:28,body:`#274b7a`,colors:[`#e8e8e8`,`#c0392b`,`#f1c40f`,`#7fb3d5`]},{name:`Reindeer Roadkill`,clash:88,body:`#6d4c41`,colors:[`#ffeb3b`,`#e53935`,`#4caf50`,`#ff9800`]}],a=[`The `,`Aunt Helga's `,`Grandpa Ole's `,`Cousin Kim's `,`The Office Party `,`Christmas 1987 `,`Mom's `],o=[`Eggnog-Soaked `,`Tinsel-Loaded `,`Radioactive `,`Cursed `,`Maximum `,`Aggressively Festive `,`Glitter-Bombed `,`Sleigh-Chasing `,`Mulled-Wine `,`Ginger-Infused `],s=[`Disaster`,`Nightmare`,`Menace`,`Warcrime`,`Masterpiece`,`Catastrophe`,`Legend`,`Special`,`Tragedy`,`Showstopper`],c=(e,t)=>t[Math.floor(e()*t.length)];function l(e){return c(e,a)+c(e,o)+c(e,s)}function u(e){return e<20?`Potentially office-safe`:e<40?`Mildly festive`:e<60?`Aunt-approved`:e<80?`Family intervention needed`:e<95?`Documented war crime`:`Nuclear`}var d=(e,t,n=!1)=>({name:e,w:t[0].length,h:t.length,rows:t,tame:n}),f=[d(`tree`,[`...##...`,`..####..`,`..####..`,`.######.`,`.######.`,`########`,`...oo...`,`...oo...`],!0),d(`snowflake`,[`#..##..#`,`.#.##.#.`,`..####..`,`########`,`########`,`..####..`,`.#.##.#.`,`#..##..#`],!0),d(`star`,[`...##...`,`..####..`,`########`,`########`,`.######.`,`..####..`,`.#.##.#.`,`#..##..#`],!0),d(`snowman`,[`...##...`,`..####..`,`.######.`,`..oooo..`,`.o#oo#o.`,`..oooo..`,`.oooooo.`,`oooooooo`],!0),d(`santa`,[`.....##.`,`....###.`,`..####..`,`########`,`.oooooo.`,`.o#oo#o.`,`.oooooo.`,`..oooo..`]),d(`reindeer`,[`#......#`,`.#....#.`,`..####..`,`.oooooo.`,`.o#oo#o.`,`.oooooo.`,`..o##o..`,`...oo...`]),d(`candycane`,[`..####..`,`.#....#.`,`#......#`,`#......#`,`...#....`,`...#....`,`...#....`,`...#....`]),d(`present`,[`..o..o..`,`.oooooo.`,`oo####oo`,`oo####oo`,`oo####oo`,`oo####oo`,`oo####oo`,`oo####oo`]),d(`gingerbread`,[`..####..`,`..####..`,`########`,`.######.`,`..####..`,`..#..#..`,`.#....#.`,`#......#`]),d(`bell`,[`...##...`,`...##...`,`..####..`,`.######.`,`.######.`,`########`,`########`,`...oo...`]),d(`heart`,[`.#....#.`,`########`,`########`,`########`,`.######.`,`..####..`,`...##...`,`........`]),d(`mitten`,[`..####..`,`.######.`,`#######.`,`######..`,`######..`,`.######.`,`.######.`,`........`]),d(`stocking`,[`..####..`,`..####..`,`..####..`,`..####..`,`..#####.`,`.#######`,`########`,`#####...`])],p=d(`flake6`,[`#.##.#`,`.####.`,`######`,`######`,`.####.`,`#.##.#`]),m=12;function h(e){let t=e>>>0;return()=>{t|=0,t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function g(e,t,n){let r=e^Math.imul(t,2654435761)^Math.imul(n,2246822507);return r=Math.imul(r^r>>>13,3266489909),r^=r>>>16,(r>>>0)/4294967296}var _=e=>[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)],v=(e,t,n)=>`#`+[e,t,n].map(e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,`0`)).join(``),y=(e,t)=>{let[n,r,i]=_(e);return v(n*t,r*t,i*t)};function b(e,t){if(e>=4&&e<=43&&t>=14&&t<=37)return(e===4||e===7)&&t>=23&&t<=28||(e===5||e===6)&&t>=22&&t<=29?0:e<=8||e>=41?3:1;if(e>=4&&e<=22){if(t>=Math.max(0,12-(e-4))&&t<=13)return e>=21?3:2;let n=Math.min(51,39+(e-4));if(t>=38&&t<=n)return e>=21?3:2}return 0}var x=(e,t,n,r,i,a)=>{let o=n-t+1,s=Math.max(1,Math.floor((o-1)/2)),c=t+s,l=2*s*2;for(let t=r;t<=i;t++){let i=(t-r)%l,o=i<l/2?i:l-i;e(c-s+o,t,a[0]),c-s+o+1<=n&&e(c-s+o+1,t,a[1])}},S=(e,t,n,r,i,a)=>{let o=Math.floor((t+n)/2);for(let n=r;n<=i;n++)(n-r)%2==0?e(o,n,a[0]):t!==o&&e(t,n,a[1])},C=[x,S,(e,t,n,r,i,a)=>{let o=Math.floor((t+n)/2);for(let s=r;s<=i;s++)for(let i=t;i<=n;i++){let t=Math.abs((s-r)%6-3)+Math.abs(i-o);t<=1?e(i,s,a[0]):t===2&&e(i,s,a[1])}},(e,t,n,r,i,a)=>{for(let o=t;o<=n;o++){let n=(o-t)%2==0?a[0]:a[1];for(let t=r;t<=i;t++)(t+o)%2==0&&e(o,t,n)}},(e,t,n,r,i,a)=>{let o=Math.floor((t+n)/2);for(let s=r;s<=i;s++)(s-r)%4==0?(e(o,s,a[0]),o-1>=t&&e(o-1,s,a[0]),o+1<=n&&e(o+1,s,a[0]),e(o,Math.min(i,s+1),a[0]),s>r&&e(o,s-1,a[0])):(s-r)%4==2&&(e(t,s,a[1]),n!==t&&e(n,s,a[1]))}];function w(e){return e.paletteId>=0&&e.paletteId<i.length?i[e.paletteId]:i[Math.abs(e.seed)%i.length]}function T(e){let t=h(e.seed),n=w(e),r=e.ugliness/100,i=[],a=[];for(let e=0;e<46;e++){i.push(Array(52).fill(null)),a.push(Array(52).fill(0));for(let t=0;t<52;t++)a[e][t]=b(e,t)}let o=(e,t,n)=>{if(e<0||e>=46||t<0||t>=52)return;let r=a[e][t];(r===1||r===2)&&(i[e][t]=n)},s=y(n.body,1.25),c=y(n.body,.72),d=y(n.body,.88);for(let e=0;e<46;e++)for(let t=0;t<52;t++)(a[e][t]===1||a[e][t]===2)&&(i[e][t]=n.body);for(let e=0;e<46;e++)for(let t=0;t<52;t++)a[e][t]===3&&(i[e][t]=e<=8?e%2==0?s:c:t%2==0?s:c);let m=2+Math.round(r*2),g=n.colors.slice(0,m),_=f.filter(e=>r<.35?e.tame:!0),v=new Set,T=(e,n,r,i,a,s)=>{e(o,n,r,i,a,s,t);for(let e of s)v.add(e)},E=(e,t,n,r,s,c,l,u,d)=>{let f=s-r+1,p=d??Math.max(1,Math.round(f/(e.w+2))),m=f/p;for(let s=0;s<p;s++){let d=Math.round(r+s*m+(m-e.w)/2);if(u!==null)for(let r=t;r<=n;r++)for(let t=d-1;t<=d+e.w;t++)(a[r][t]===1||a[r][t]===2)&&(i[r][t]=u);for(let n=0;n<e.h;n++)for(let r=0;r<e.w;r++){let i=e.rows[n][r];i===`#`?o(t+n,d+r,c):i===`o`&&o(t+n,d+r,l)}}v.add(c),u!==null&&v.add(u)},D=[..._].sort(()=>t()-.5),O=D[0],k=D[1%D.length],A=r>.5?D[2%D.length]:O,j=C[Math.floor(t()*C.length)];C[Math.floor(t()*C.length)];let M=r>.4?j:x,N=g[0],P=g[1%g.length],F=g[2%g.length],I=g[3%g.length],L=r>.45?g[Math.floor(t()*g.length)]:null;M(o,9,11,14,37,[P,d],t),E(O,12,19,14,37,N,P,L),T(j,20,22,14,37,[F,I]),E(k,23,30,14,37,P,F,L),T(S,31,32,14,37,[I,N]),E(A,33,40,14,37,F,I,L);for(let[e,n]of[[0,13],[38,51]])x(o,9,11,e,n,[F,d],t),E(p,12,17,e,n,N,P,null,1),S(o,18,20,e,n,[I,d],t);let R=l(t),z=v.size,B=Math.max(4,Math.min(100,Math.round(n.clash*(.55+.45*r)+z*3+(L===null?0:6)+t()*8)));return{config:e,palette:n,name:R,embarrassment:B,label:u(B),cells:i}}function E(e,t){let n=Math.min(2,window.devicePixelRatio||1);e.width=624*n,e.height=552*n;let r=e.getContext(`2d`);r.scale(n,n),r.clearRect(0,0,624,552);let i=t.config.seed>>>0,a=.05+t.config.ugliness/100*.05;for(let e=0;e<46;e++)for(let n=0;n<52;n++){let o=t.cells[e]?.[n]??null;if(o===null)continue;let s=n*m,c=e*m,l=y(o,1+(g(i,n,e)-.5)*2*a);r.fillStyle=l,r.fillRect(s,c,m,m),r.strokeStyle=y(l,.86),r.lineWidth=1.6,r.beginPath(),r.moveTo(s+1,c+2.5),r.lineTo(s+m/2,c+m-2),r.lineTo(s+m-1,c+2.5),r.stroke(),r.strokeStyle=y(l,1.12),r.lineWidth=1,r.beginPath(),r.moveTo(s+1,c+1.5),r.lineTo(s+m/2,c+m-3),r.stroke()}r.strokeStyle=`rgba(0,0,0,0.35)`,r.lineWidth=1;for(let e=0;e<46;e++)for(let n=0;n<52;n++){if(t.cells[e][n]===null)continue;let i=n*m,a=e*m,o=(r,i)=>{let a=e+r,o=n+i;return a<0||a>=46||o<0||o>=52||t.cells[a][o]===null};r.beginPath(),o(-1,0)&&(r.moveTo(i,a),r.lineTo(i+m,a)),o(1,0)&&(r.moveTo(i,a+m),r.lineTo(i+m,a+m)),o(0,-1)&&(r.moveTo(i,a),r.lineTo(i,a+m)),o(0,1)&&(r.moveTo(i+m,a),r.lineTo(i+m,a+m)),r.stroke()}}var D=document.querySelector(`#app`);if(D===null)throw Error(`Missing #app in index.html`);var O=`aos02-ugly-sweater`;function k(){try{let e=localStorage.getItem(O);if(e!==null){let t=JSON.parse(e);if(typeof t.seed==`number`&&typeof t.paletteId==`number`&&typeof t.ugliness==`number`)return{seed:t.seed,paletteId:t.paletteId,ugliness:t.ugliness}}}catch{}return{seed:Math.floor(Math.random()*1e6),paletteId:-1,ugliness:65}}function A(e){localStorage.setItem(O,JSON.stringify(e))}var j=k();D.innerHTML=` + <div class="wrap"> + <header> + <h1>๐Ÿงถ Ugly Sweater Forge</h1> + <p class="sub">Procedurally knitted crimes against fashion. Every stitch is deterministic โ€” share the seed.</p> + </header> + <div class="layout"> + <div class="stage"> + <canvas id="sweater" aria-label="Generated ugly Christmas sweater"></canvas> + </div> + <aside class="panel"> + <div class="name-card"> + <div class="sweater-name" id="name"></div> + <div class="meter-row"> + <span class="meter-label">Embarrassment</span> + <div class="meter"><div class="meter-fill" id="meter"></div></div> + <span class="meter-score" id="score"></span> + </div> + <div class="meter-verdict" id="verdict"></div> + <div class="palette-line" id="palette-line"></div> + </div> + <div class="controls"> + <button id="knit" class="big">๐Ÿงถ Knit a new sweater</button> + <label class="ctl"> + <span>Ugliness <b id="ugl-val"></b></span> + <input type="range" id="ugliness" min="0" max="100" step="1"> + </label> + <label class="ctl"> + <span>Yarn palette</span> + <select id="palette"></select> + </label> + <label class="ctl"> + <span>Seed</span> + <div class="seed-row"> + <input type="number" id="seed" min="0" max="999999" step="1"> + <button id="copy-seed" title="Copy seed">๐Ÿ“‹</button> + </div> + </label> + <button id="download">โฌ‡๏ธ Save as PNG</button> + </div> + <p class="hint">Low ugliness knits tasteful Nordic patterns. Push it up until HR gets involved.</p> + </aside> + </div> + </div> +`;var M=document.querySelector(`#sweater`),N=document.querySelector(`#name`),P=document.querySelector(`#meter`),F=document.querySelector(`#score`),I=document.querySelector(`#verdict`),L=document.querySelector(`#palette-line`),R=document.querySelector(`#ugliness`),z=document.querySelector(`#ugl-val`),B=document.querySelector(`#palette`),V=document.querySelector(`#seed`);B.innerHTML=`<option value="-1">๐ŸŽฒ Surprise me</option>`+i.map((e,t)=>`<option value="${t}">${e.name}</option>`).join(``);function H(){let e=T(j);E(M,e),N.textContent=`โ€œ${e.name}โ€`,P.style.width=e.embarrassment+`%`,P.style.background=`linear-gradient(90deg, #4caf50, #ffc107 55%, #f44336)`,F.textContent=String(e.embarrassment),I.textContent=e.label,L.textContent=`Yarn: ${e.palette.name}`,z.textContent=j.ugliness>=85?`โ˜ ๏ธ`:String(j.ugliness),A(j)}function U(){R.value=String(j.ugliness),B.value=String(j.paletteId),V.value=String(j.seed)}document.querySelector(`#knit`).addEventListener(`click`,()=>{j.seed=Math.floor(Math.random()*1e6),U(),H()}),R.addEventListener(`input`,()=>{j.ugliness=Number(R.value),H()}),B.addEventListener(`change`,()=>{j.paletteId=Number(B.value),H()}),V.addEventListener(`change`,()=>{let e=Math.floor(Number(V.value));j.seed=Number.isFinite(e)?Math.max(0,Math.min(999999,e)):0,V.value=String(j.seed),H()}),document.querySelector(`#copy-seed`).addEventListener(`click`,e=>{navigator.clipboard.writeText(String(j.seed));let t=e.currentTarget;t.textContent=`โœ“`,setTimeout(()=>t.textContent=`๐Ÿ“‹`,900)}),document.querySelector(`#download`).addEventListener(`click`,()=>{M.toBlob(e=>{if(e===null)return;let t=document.createElement(`a`);t.href=URL.createObjectURL(e),t.download=`ugly-sweater-${j.seed}.png`,t.click(),URL.revokeObjectURL(t.href)},`image/png`)}),U(),H(); \ No newline at end of file diff --git a/check_tame.png b/check_tame.png new file mode 100644 index 0000000..ad6271b Binary files /dev/null and b/check_tame.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..5ba5632 --- /dev/null +++ b/index.html @@ -0,0 +1,22 @@ +<!doctype html> +<html lang="en"> + <head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + <title>Ugly Sweater Forge โ€” Advent of AI Slop Day 2 + + + + + + + + + + + + + +
+ + diff --git a/package.json b/package.json new file mode 100644 index 0000000..8de90c5 --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "name": "advent-of-slop-entry", + "type": "module", + "private": true, + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "preview": "vite preview" + }, + "packageManager": "pnpm@11.5.2", + "devDependencies": { + "typescript": "^7.0.2", + "vite": "^8.3.8" + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..e13864f --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,717 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + devDependencies: + typescript: + specifier: ^7.0.2 + version: 7.0.2 + vite: + specifier: ^8.3.8 + version: 8.3.8 + +packages: + + '@emnapi/core@2.0.0-beta.2': + resolution: {integrity: sha512-MzCVoWtcg4Pm2B3je5mMvYMvj3MmBKw+fU7vbsJc9/iT8ip6/eYIHo/Dsm/mr+wsHB6SEyJDuxB09Yy6r/8+4A==} + + '@emnapi/runtime@2.0.0-beta.2': + resolution: {integrity: sha512-JcrSPzPvZuNZvJqPTF9Fw25LbOJ8avzFVlaf2grmH4Cku0oGP47tRgqPZadcfj3YoZMHkFVnCYFbQM8I+i5QEw==} + + '@emnapi/wasi-threads@2.2.0': + resolution: {integrity: sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==} + + '@napi-rs/wasm-runtime@1.2.6': + resolution: {integrity: sha512-mRyDmEw9/fCDXCGfL1sbgIw/GUK0PVxRW4YwgPN61F3LQ+fSyoBFarJVzgGyhF6kRzEQZ0FejDqm4WLXSeqQmw==} + engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0} + peerDependencies: + '@emnapi/core': ^1.7.1 || 2.0.0-beta.2 + '@emnapi/runtime': ^1.7.1 || 2.0.0-beta.2 + + '@oxc-project/types@0.156.0': + resolution: {integrity: sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw==} + + '@rolldown/binding-android-arm-eabi@1.2.19': + resolution: {integrity: sha512-e+Ebe0WT+9tbXmNKPIiC8YrWAHYwug3m6i4p3rZGGulfZri1jtI4HslT+OZnFf/OIHowWF71DTlHwXBP2SiA7A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [android] + + '@rolldown/binding-android-arm64@1.2.19': + resolution: {integrity: sha512-hOombrTJ+szt2ciEzS7oCA78lMPBgF5UMQWCJIyNfnrI7GLl8HYoFqCnpL2gcPOaXMqryGCU5ExdQKyDDcC+yA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@rolldown/binding-darwin-arm64@1.2.19': + resolution: {integrity: sha512-XoMA2pwCKGTQzUjPgtRwkedH4WmXhdIPKT6l6oOxd1PUbNodGI6DcBekgN7EC//+x3pfBYX/qL1gNmZAqivw5g==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@rolldown/binding-darwin-x64@1.2.19': + resolution: {integrity: sha512-zo8EsSSwMZCY/e+fRnGaX02YGgvJD0yvhNi/9hpGPA2MJ9ZF8dPCw75UGfpI6OpQ/myR/dIYmogRvqiZD0TrXg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@rolldown/binding-freebsd-x64@1.2.19': + resolution: {integrity: sha512-O8ISAOfI1nj7AuBPd30FSF47z7f7lzlk5poQVGgiikvQuGEBFYvW8ki+UEnT+YJPnNGjQzn304klt4O9FUE7mA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@rolldown/binding-linux-arm-gnueabihf@1.2.19': + resolution: {integrity: sha512-/lYCba5NO0yq4S0jGMH8QTBtkvQxoXjoQWzF5BcWp9MjB9jxVRD1GQDNofkVjcOj30DWyhLIN/4Oe60JKzaONw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@rolldown/binding-linux-arm64-gnu@1.2.19': + resolution: {integrity: sha512-pm/apFMBnSbFb3O6nG5pHO1iqHhZrjGDFEjSm+ot9J17XXPvH9L90y5h+jgfHCE+Qdlsvy8qKEcU4VKxgjD+vA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-arm64-musl@1.2.19': + resolution: {integrity: sha512-K1SmQp3FFichn8oqrNIwvFoZ5wcvjC7goBzpaMNvLf9FZc+QB/QvLmnpJZgAAGHiD980tP8FZZnXk2K94rvlxg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@rolldown/binding-linux-ppc64-gnu@1.2.19': + resolution: {integrity: sha512-I0xwD57jP/3A7+5UPZin2w8Y7XHEmEM5zqpYZOcQ45MlNW6tUJUziymV3yRr7rL4vwyfEcRsRksC4a7Kc08p5Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-s390x-gnu@1.2.19': + resolution: {integrity: sha512-BrtEHT24SNXj9HiXqy+s/kXiSiQGt6EKCPUlRirAoIioVxKGnbXBUEkbZASAei7iZJB0/Ynm+0JP00Ipx7AnSw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-gnu@1.2.19': + resolution: {integrity: sha512-rm75/9DkHKeU2WnA8w4X94WGYgLlDCFCfkQC+4bguVJmC/jvDRv2B+2wLOYhyE0fVuv7//Ckk39OoOufyCu76Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-musl@1.2.19': + resolution: {integrity: sha512-irh/4+iYFM4GAzpluDErgjz89bj6NDtqqMAG/6O1LG38Ed3NpyebzCpcVNkFW8uhy+/3/BocUvnXDR33CXWe9A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@rolldown/binding-openharmony-arm64@1.2.19': + resolution: {integrity: sha512-+KWTWNoPt+CfSq94CiceWu3yPE+QzkaG+phPyz9G60tmZLwfQkcA4AeksafzvJAw4pvg1mcd5a1TkUqVv0s4JA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@rolldown/binding-wasm32-wasi@1.2.19': + resolution: {integrity: sha512-7EH+skOsl5qpWnK0vzamgJFhOv1cwxQpsxm8tI883K9fur5c27p8q87fzEO6BbBPabA2/+s/zR63/pLc137iOg==} + engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0} + cpu: [wasm32] + + '@rolldown/binding-win32-arm64-msvc@1.2.19': + resolution: {integrity: sha512-3Q1Yg1Q7tEvBWoZf5rFvG/GKZQPgwfru+p4wBajDfJFBs0SHCpL++dfTjW9gyAKd1T7ZpIYvdaUax7Pa/IhFVQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@rolldown/binding-win32-x64-msvc@1.2.19': + resolution: {integrity: sha512-y/sqRRc6d7hECzOFc5n3LSeqctmIp9mMjY1Kq4s14uLPd/LZ4z7i1zrW6fMtp2mPeuQIC4e6ULMcwQzMomqQag==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + + '@rolldown/pluginutils@1.1.1': + resolution: {integrity: sha512-glFIJDvLNDtJhT9qrMFWLPbvS+skxgt4L0K8Ei2YtnhPysAJnsI7nyxSJxKj4ADeKX0OLjC4ntRkwpLOoS3rwA==} + + '@tybys/wasm-util@0.10.5': + resolution: {integrity: sha512-dOGOPxlaNV+G046mZzN+9C0dAcQZeSKcXiVaM0TYy/LM4ttTmgSBDxYfovcYI8Em3+eAbiAYpvWLOv8+ZVRJKA==} + + '@typescript/typescript-aix-ppc64@7.0.2': + resolution: {integrity: sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ==} + engines: {node: '>=16.20.0'} + cpu: [ppc64] + os: [aix] + + '@typescript/typescript-darwin-arm64@7.0.2': + resolution: {integrity: sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [darwin] + + '@typescript/typescript-darwin-x64@7.0.2': + resolution: {integrity: sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [darwin] + + '@typescript/typescript-freebsd-arm64@7.0.2': + resolution: {integrity: sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [freebsd] + + '@typescript/typescript-freebsd-x64@7.0.2': + resolution: {integrity: sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [freebsd] + + '@typescript/typescript-linux-arm64@7.0.2': + resolution: {integrity: sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [linux] + + '@typescript/typescript-linux-arm@7.0.2': + resolution: {integrity: sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ==} + engines: {node: '>=16.20.0'} + cpu: [arm] + os: [linux] + + '@typescript/typescript-linux-loong64@7.0.2': + resolution: {integrity: sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ==} + engines: {node: '>=16.20.0'} + cpu: [loong64] + os: [linux] + + '@typescript/typescript-linux-mips64el@7.0.2': + resolution: {integrity: sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA==} + engines: {node: '>=16.20.0'} + cpu: [mips64el] + os: [linux] + + '@typescript/typescript-linux-ppc64@7.0.2': + resolution: {integrity: sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA==} + engines: {node: '>=16.20.0'} + cpu: [ppc64] + os: [linux] + + '@typescript/typescript-linux-riscv64@7.0.2': + resolution: {integrity: sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ==} + engines: {node: '>=16.20.0'} + cpu: [riscv64] + os: [linux] + + '@typescript/typescript-linux-s390x@7.0.2': + resolution: {integrity: sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw==} + engines: {node: '>=16.20.0'} + cpu: [s390x] + os: [linux] + + '@typescript/typescript-linux-x64@7.0.2': + resolution: {integrity: sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [linux] + + '@typescript/typescript-netbsd-arm64@7.0.2': + resolution: {integrity: sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [netbsd] + + '@typescript/typescript-netbsd-x64@7.0.2': + resolution: {integrity: sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [netbsd] + + '@typescript/typescript-openbsd-arm64@7.0.2': + resolution: {integrity: sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [openbsd] + + '@typescript/typescript-openbsd-x64@7.0.2': + resolution: {integrity: sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [openbsd] + + '@typescript/typescript-sunos-x64@7.0.2': + resolution: {integrity: sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [sunos] + + '@typescript/typescript-win32-arm64@7.0.2': + resolution: {integrity: sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [win32] + + '@typescript/typescript-win32-x64@7.0.2': + resolution: {integrity: sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [win32] + + detect-libc@2.1.2: + resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==} + engines: {node: '>=8'} + + fdir@6.5.0: + resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} + engines: {node: '>=12.0.0'} + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + + fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + + lightningcss-android-arm64@1.33.0: + resolution: {integrity: sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [android] + + lightningcss-darwin-arm64@1.33.0: + resolution: {integrity: sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [darwin] + + lightningcss-darwin-x64@1.33.0: + resolution: {integrity: sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [darwin] + + lightningcss-freebsd-x64@1.33.0: + resolution: {integrity: sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [freebsd] + + lightningcss-linux-arm-gnueabihf@1.33.0: + resolution: {integrity: sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm] + os: [linux] + + lightningcss-linux-arm64-gnu@1.33.0: + resolution: {integrity: sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [glibc] + + lightningcss-linux-arm64-musl@1.33.0: + resolution: {integrity: sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [musl] + + lightningcss-linux-x64-gnu@1.33.0: + resolution: {integrity: sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [glibc] + + lightningcss-linux-x64-musl@1.33.0: + resolution: {integrity: sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [musl] + + lightningcss-win32-arm64-msvc@1.33.0: + resolution: {integrity: sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [win32] + + lightningcss-win32-x64-msvc@1.33.0: + resolution: {integrity: sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [win32] + + lightningcss@1.33.0: + resolution: {integrity: sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==} + engines: {node: '>= 12.0.0'} + + nanoid@3.3.20: + resolution: {integrity: sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true + + picocolors@1.1.1: + resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + + picomatch@4.0.7: + resolution: {integrity: sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==} + engines: {node: '>=12'} + + postcss@8.5.33: + resolution: {integrity: sha512-RVHEU9/Pp1Fnjr/MpAJsZoADukCKhfIi15OunEYiGktIkYLkPVvC1sioWolGDS7XByMTx9m/IGbro0Js13zhnQ==} + engines: {node: ^10 || ^12 || >=14} + + rolldown@1.2.19: + resolution: {integrity: sha512-QIiV1J9d0pzN4jeeTH4sjPy0AZ6cAy2cG0ExeoE1+U8Rvj+hR3gYkokx0YbeUNGlZqiQJJ2utcETe0oKXwzsuA==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + + source-map-js@1.2.4: + resolution: {integrity: sha512-J7ZjMvHd9O1fcT/5V09QWaaSl2BbWx3F6O08spde82Namf9UB0GxRVIPiNbVsdKkoizHiSpTodo3vp2bAy91MA==} + engines: {node: '>=6.0.0'} + + tinyglobby@0.2.17: + resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==} + engines: {node: '>=12.0.0'} + + tslib@2.9.1: + resolution: {integrity: sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==} + + typescript@7.0.2: + resolution: {integrity: sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA==} + engines: {node: '>=16.20.0'} + hasBin: true + + vite@8.3.8: + resolution: {integrity: sha512-LzOn3h9rG/0vhLdXrV4yJ4QFA9eEoqCl+Yx+kGJd7aB9w6nfNgVHKSYwLPZUHrz4ZGa+t+kXjV9itvcHDLQouA==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + peerDependencies: + '@types/node': ^20.19.0 || >=22.12.0 + '@vitejs/devtools': ^0.7.1 || ^0.8.0 + esbuild: ^0.27.0 || ^0.28.0 + jiti: '>=1.21.0' + less: ^4.0.0 + sass: ^1.70.0 + sass-embedded: ^1.70.0 + stylus: '>=0.54.8' + sugarss: ^5.0.0 + terser: ^5.16.0 + tsx: ^4.8.1 + yaml: ^2.4.2 + peerDependenciesMeta: + '@types/node': + optional: true + '@vitejs/devtools': + optional: true + esbuild: + optional: true + jiti: + optional: true + less: + optional: true + sass: + optional: true + sass-embedded: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + tsx: + optional: true + yaml: + optional: true + +snapshots: + + '@emnapi/core@2.0.0-beta.2': + dependencies: + '@emnapi/wasi-threads': 2.2.0 + tslib: 2.9.1 + optional: true + + '@emnapi/runtime@2.0.0-beta.2': + dependencies: + tslib: 2.9.1 + optional: true + + '@emnapi/wasi-threads@2.2.0': + dependencies: + tslib: 2.9.1 + optional: true + + '@napi-rs/wasm-runtime@1.2.6(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2)': + dependencies: + '@emnapi/core': 2.0.0-beta.2 + '@emnapi/runtime': 2.0.0-beta.2 + '@tybys/wasm-util': 0.10.5 + optional: true + + '@oxc-project/types@0.156.0': {} + + '@rolldown/binding-android-arm-eabi@1.2.19': + optional: true + + '@rolldown/binding-android-arm64@1.2.19': + optional: true + + '@rolldown/binding-darwin-arm64@1.2.19': + optional: true + + '@rolldown/binding-darwin-x64@1.2.19': + optional: true + + '@rolldown/binding-freebsd-x64@1.2.19': + optional: true + + '@rolldown/binding-linux-arm-gnueabihf@1.2.19': + optional: true + + '@rolldown/binding-linux-arm64-gnu@1.2.19': + optional: true + + '@rolldown/binding-linux-arm64-musl@1.2.19': + optional: true + + '@rolldown/binding-linux-ppc64-gnu@1.2.19': + optional: true + + '@rolldown/binding-linux-s390x-gnu@1.2.19': + optional: true + + '@rolldown/binding-linux-x64-gnu@1.2.19': + optional: true + + '@rolldown/binding-linux-x64-musl@1.2.19': + optional: true + + '@rolldown/binding-openharmony-arm64@1.2.19': + optional: true + + '@rolldown/binding-wasm32-wasi@1.2.19': + dependencies: + '@emnapi/core': 2.0.0-beta.2 + '@emnapi/runtime': 2.0.0-beta.2 + '@napi-rs/wasm-runtime': 1.2.6(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2) + optional: true + + '@rolldown/binding-win32-arm64-msvc@1.2.19': + optional: true + + '@rolldown/binding-win32-x64-msvc@1.2.19': + optional: true + + '@rolldown/pluginutils@1.1.1': {} + + '@tybys/wasm-util@0.10.5': + dependencies: + tslib: 2.9.1 + optional: true + + '@typescript/typescript-aix-ppc64@7.0.2': + optional: true + + '@typescript/typescript-darwin-arm64@7.0.2': + optional: true + + '@typescript/typescript-darwin-x64@7.0.2': + optional: true + + '@typescript/typescript-freebsd-arm64@7.0.2': + optional: true + + '@typescript/typescript-freebsd-x64@7.0.2': + optional: true + + '@typescript/typescript-linux-arm64@7.0.2': + optional: true + + '@typescript/typescript-linux-arm@7.0.2': + optional: true + + '@typescript/typescript-linux-loong64@7.0.2': + optional: true + + '@typescript/typescript-linux-mips64el@7.0.2': + optional: true + + '@typescript/typescript-linux-ppc64@7.0.2': + optional: true + + '@typescript/typescript-linux-riscv64@7.0.2': + optional: true + + '@typescript/typescript-linux-s390x@7.0.2': + optional: true + + '@typescript/typescript-linux-x64@7.0.2': + optional: true + + '@typescript/typescript-netbsd-arm64@7.0.2': + optional: true + + '@typescript/typescript-netbsd-x64@7.0.2': + optional: true + + '@typescript/typescript-openbsd-arm64@7.0.2': + optional: true + + '@typescript/typescript-openbsd-x64@7.0.2': + optional: true + + '@typescript/typescript-sunos-x64@7.0.2': + optional: true + + '@typescript/typescript-win32-arm64@7.0.2': + optional: true + + '@typescript/typescript-win32-x64@7.0.2': + optional: true + + detect-libc@2.1.2: {} + + fdir@6.5.0(picomatch@4.0.7): + optionalDependencies: + picomatch: 4.0.7 + + fsevents@2.3.3: + optional: true + + lightningcss-android-arm64@1.33.0: + optional: true + + lightningcss-darwin-arm64@1.33.0: + optional: true + + lightningcss-darwin-x64@1.33.0: + optional: true + + lightningcss-freebsd-x64@1.33.0: + optional: true + + lightningcss-linux-arm-gnueabihf@1.33.0: + optional: true + + lightningcss-linux-arm64-gnu@1.33.0: + optional: true + + lightningcss-linux-arm64-musl@1.33.0: + optional: true + + lightningcss-linux-x64-gnu@1.33.0: + optional: true + + lightningcss-linux-x64-musl@1.33.0: + optional: true + + lightningcss-win32-arm64-msvc@1.33.0: + optional: true + + lightningcss-win32-x64-msvc@1.33.0: + optional: true + + lightningcss@1.33.0: + dependencies: + detect-libc: 2.1.2 + optionalDependencies: + lightningcss-android-arm64: 1.33.0 + lightningcss-darwin-arm64: 1.33.0 + lightningcss-darwin-x64: 1.33.0 + lightningcss-freebsd-x64: 1.33.0 + lightningcss-linux-arm-gnueabihf: 1.33.0 + lightningcss-linux-arm64-gnu: 1.33.0 + lightningcss-linux-arm64-musl: 1.33.0 + lightningcss-linux-x64-gnu: 1.33.0 + lightningcss-linux-x64-musl: 1.33.0 + lightningcss-win32-arm64-msvc: 1.33.0 + lightningcss-win32-x64-msvc: 1.33.0 + + nanoid@3.3.20: {} + + picocolors@1.1.1: {} + + picomatch@4.0.7: {} + + postcss@8.5.33: + dependencies: + nanoid: 3.3.20 + picocolors: 1.1.1 + source-map-js: 1.2.4 + + rolldown@1.2.19: + dependencies: + '@oxc-project/types': 0.156.0 + '@rolldown/pluginutils': 1.1.1 + optionalDependencies: + '@rolldown/binding-android-arm-eabi': 1.2.19 + '@rolldown/binding-android-arm64': 1.2.19 + '@rolldown/binding-darwin-arm64': 1.2.19 + '@rolldown/binding-darwin-x64': 1.2.19 + '@rolldown/binding-freebsd-x64': 1.2.19 + '@rolldown/binding-linux-arm-gnueabihf': 1.2.19 + '@rolldown/binding-linux-arm64-gnu': 1.2.19 + '@rolldown/binding-linux-arm64-musl': 1.2.19 + '@rolldown/binding-linux-ppc64-gnu': 1.2.19 + '@rolldown/binding-linux-s390x-gnu': 1.2.19 + '@rolldown/binding-linux-x64-gnu': 1.2.19 + '@rolldown/binding-linux-x64-musl': 1.2.19 + '@rolldown/binding-openharmony-arm64': 1.2.19 + '@rolldown/binding-wasm32-wasi': 1.2.19 + '@rolldown/binding-win32-arm64-msvc': 1.2.19 + '@rolldown/binding-win32-x64-msvc': 1.2.19 + + source-map-js@1.2.4: {} + + tinyglobby@0.2.17: + dependencies: + fdir: 6.5.0(picomatch@4.0.7) + picomatch: 4.0.7 + + tslib@2.9.1: + optional: true + + typescript@7.0.2: + optionalDependencies: + '@typescript/typescript-aix-ppc64': 7.0.2 + '@typescript/typescript-darwin-arm64': 7.0.2 + '@typescript/typescript-darwin-x64': 7.0.2 + '@typescript/typescript-freebsd-arm64': 7.0.2 + '@typescript/typescript-freebsd-x64': 7.0.2 + '@typescript/typescript-linux-arm': 7.0.2 + '@typescript/typescript-linux-arm64': 7.0.2 + '@typescript/typescript-linux-loong64': 7.0.2 + '@typescript/typescript-linux-mips64el': 7.0.2 + '@typescript/typescript-linux-ppc64': 7.0.2 + '@typescript/typescript-linux-riscv64': 7.0.2 + '@typescript/typescript-linux-s390x': 7.0.2 + '@typescript/typescript-linux-x64': 7.0.2 + '@typescript/typescript-netbsd-arm64': 7.0.2 + '@typescript/typescript-netbsd-x64': 7.0.2 + '@typescript/typescript-openbsd-arm64': 7.0.2 + '@typescript/typescript-openbsd-x64': 7.0.2 + '@typescript/typescript-sunos-x64': 7.0.2 + '@typescript/typescript-win32-arm64': 7.0.2 + '@typescript/typescript-win32-x64': 7.0.2 + + vite@8.3.8: + dependencies: + lightningcss: 1.33.0 + picomatch: 4.0.7 + postcss: 8.5.33 + rolldown: 1.2.19 + tinyglobby: 0.2.17 + optionalDependencies: + fsevents: 2.3.3 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..6d40426 --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,5 @@ +# Only install package versions published at least 7 days ago (in minutes). +minimumReleaseAge: 10080 + +allowBuilds: + esbuild: true diff --git a/preview.png b/preview.png new file mode 100644 index 0000000..030df5e Binary files /dev/null and b/preview.png differ diff --git a/preview_shot.png b/preview_shot.png new file mode 100644 index 0000000..9abddde Binary files /dev/null and b/preview_shot.png differ diff --git a/public/preview.png b/public/preview.png new file mode 100644 index 0000000..9abddde Binary files /dev/null and b/public/preview.png differ diff --git a/src/badge.ts b/src/badge.ts new file mode 100644 index 0000000..c81df86 --- /dev/null +++ b/src/badge.ts @@ -0,0 +1,56 @@ +// : the label in the top right corner, "Advent of AI Slop [Day 1] +// Living fishtank". Its first part links to the calendar, the rest to the door of the day this was made for. +// It draws itself in a shadow root, so its styles and the page's never touch. +const site = 'https://advent-of-slop.quesma.com'; + +const css = ` + nav { + position: fixed; + top: 0; + right: 0; + z-index: 2147483647; + display: flex; + flex-wrap: wrap; + gap: 0 0.35em; + max-width: 100vw; + box-sizing: border-box; + padding: 0.35rem 0.7rem; + border-bottom-left-radius: 0.5rem; + background: #b8232f; + font: 700 0.8125rem/1.2 system-ui, sans-serif; + } + a { + color: #f6ecd6; + text-decoration: none; + } + a:hover { + text-decoration: underline; + } +`; + +const link = (href: string, text: string): HTMLAnchorElement => { + const anchor = document.createElement('a'); + anchor.href = href; + anchor.textContent = text; + return anchor; +}; + +class AdventBadge extends HTMLElement { + connectedCallback(): void { + const day = Number(this.getAttribute('day')); + if (!Number.isInteger(day) || day < 1 || day > 24) { + throw new Error(` needs day="1" to day="24", got ${this.getAttribute('day')}`); + } + const name = this.getAttribute('name'); + if (name === null || name.trim() === '') { + throw new Error(' needs name="...", the title of its day, such as name="Living fishtank"'); + } + const style = document.createElement('style'); + style.textContent = css; + const label = document.createElement('nav'); + label.append(link(`${site}/`, 'Advent of AI Slop'), link(`${site}/day/${day}/`, `[Day ${day}] ${name}`)); + this.attachShadow({ mode: 'open' }).append(style, label); + } +} + +customElements.define('advent-badge', AdventBadge); diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..4824524 --- /dev/null +++ b/src/main.ts @@ -0,0 +1,155 @@ +// Ugly Sweater Forge โ€” page wiring: controls, persistence, download. + +import './style.css'; +import { PALETTES } from './palettes'; +import { generate, render, type SweaterConfig } from './sweater'; + +const app = document.querySelector('#app'); +if (app === null) throw new Error('Missing #app in index.html'); + +const STORE_KEY = 'aos02-ugly-sweater'; + +function loadConfig(): SweaterConfig { + try { + const raw = localStorage.getItem(STORE_KEY); + if (raw !== null) { + const p = JSON.parse(raw) as Partial; + if (typeof p.seed === 'number' && typeof p.paletteId === 'number' && typeof p.ugliness === 'number') { + return { seed: p.seed, paletteId: p.paletteId, ugliness: p.ugliness }; + } + } + } catch { + // fall through to a fresh sweater + } + return { seed: Math.floor(Math.random() * 1_000_000), paletteId: -1, ugliness: 65 }; +} + +function saveConfig(cfg: SweaterConfig): void { + localStorage.setItem(STORE_KEY, JSON.stringify(cfg)); +} + +const config = loadConfig(); + +app.innerHTML = ` +
+
+

๐Ÿงถ Ugly Sweater Forge

+

Procedurally knitted crimes against fashion. Every stitch is deterministic โ€” share the seed.

+
+
+
+ +
+ +
+
+`; + +const canvas = document.querySelector('#sweater')!; +const nameEl = document.querySelector('#name')!; +const meterEl = document.querySelector('#meter')!; +const scoreEl = document.querySelector('#score')!; +const verdictEl = document.querySelector('#verdict')!; +const paletteLineEl = document.querySelector('#palette-line')!; +const uglEl = document.querySelector('#ugliness')!; +const uglValEl = document.querySelector('#ugl-val')!; +const paletteEl = document.querySelector('#palette')!; +const seedEl = document.querySelector('#seed')!; + +paletteEl.innerHTML = + '' + + PALETTES.map((p, i) => ``).join(''); + +function redraw(): void { + const sweater = generate(config); + render(canvas, sweater); + nameEl.textContent = `โ€œ${sweater.name}โ€`; + meterEl.style.width = sweater.embarrassment + '%'; + meterEl.style.background = 'linear-gradient(90deg, #4caf50, #ffc107 55%, #f44336)'; + scoreEl.textContent = String(sweater.embarrassment); + verdictEl.textContent = sweater.label; + paletteLineEl.textContent = `Yarn: ${sweater.palette.name}`; + uglValEl.textContent = config.ugliness >= 85 ? 'โ˜ ๏ธ' : String(config.ugliness); + saveConfig(config); +} + +function syncControls(): void { + uglEl.value = String(config.ugliness); + paletteEl.value = String(config.paletteId); + seedEl.value = String(config.seed); +} + +document.querySelector('#knit')!.addEventListener('click', () => { + config.seed = Math.floor(Math.random() * 1_000_000); + syncControls(); + redraw(); +}); + +uglEl.addEventListener('input', () => { + config.ugliness = Number(uglEl.value); + redraw(); +}); + +paletteEl.addEventListener('change', () => { + config.paletteId = Number(paletteEl.value); + redraw(); +}); + +seedEl.addEventListener('change', () => { + const v = Math.floor(Number(seedEl.value)); + config.seed = Number.isFinite(v) ? Math.max(0, Math.min(999999, v)) : 0; + seedEl.value = String(config.seed); + redraw(); +}); + +document.querySelector('#copy-seed')!.addEventListener('click', (ev) => { + void navigator.clipboard.writeText(String(config.seed)); + const btn = ev.currentTarget as HTMLButtonElement; + btn.textContent = 'โœ“'; + setTimeout(() => (btn.textContent = '๐Ÿ“‹'), 900); +}); + +document.querySelector('#download')!.addEventListener('click', () => { + canvas.toBlob((blob) => { + if (blob === null) return; + const a = document.createElement('a'); + a.href = URL.createObjectURL(blob); + a.download = `ugly-sweater-${config.seed}.png`; + a.click(); + URL.revokeObjectURL(a.href); + }, 'image/png'); +}); + +syncControls(); +redraw(); diff --git a/src/motifs.ts b/src/motifs.ts new file mode 100644 index 0000000..e0459d3 --- /dev/null +++ b/src/motifs.ts @@ -0,0 +1,161 @@ +// Cross-stitch pixel motifs for the sweater bands. '#' = motif color, '.' = transparent. + +export interface Motif { + name: string; + w: number; + h: number; + rows: string[]; + tame: boolean; // fits a low-ugliness sweater +} + +const m = (name: string, rows: string[], tame = false): Motif => ({ + name, + w: rows[0]!.length, + h: rows.length, + rows, + tame, +}); + +// '#' = primary motif color, 'o' = secondary color (face/fill), '.' = transparent. +export const MOTIFS: Motif[] = [ + m('tree', [ + '...##...', + '..####..', + '..####..', + '.######.', + '.######.', + '########', + '...oo...', + '...oo...', + ], true), + m('snowflake', [ + '#..##..#', + '.#.##.#.', + '..####..', + '########', + '########', + '..####..', + '.#.##.#.', + '#..##..#', + ], true), + m('star', [ + '...##...', + '..####..', + '########', + '########', + '.######.', + '..####..', + '.#.##.#.', + '#..##..#', + ], true), + m('snowman', [ + '...##...', + '..####..', + '.######.', + '..oooo..', + '.o#oo#o.', + '..oooo..', + '.oooooo.', + 'oooooooo', + ], true), + m('santa', [ + '.....##.', + '....###.', + '..####..', + '########', + '.oooooo.', + '.o#oo#o.', + '.oooooo.', + '..oooo..', + ]), + m('reindeer', [ + '#......#', + '.#....#.', + '..####..', + '.oooooo.', + '.o#oo#o.', + '.oooooo.', + '..o##o..', + '...oo...', + ]), + m('candycane', [ + '..####..', + '.#....#.', + '#......#', + '#......#', + '...#....', + '...#....', + '...#....', + '...#....', + ]), + m('present', [ + '..o..o..', + '.oooooo.', + 'oo####oo', + 'oo####oo', + 'oo####oo', + 'oo####oo', + 'oo####oo', + 'oo####oo', + ]), + m('gingerbread', [ + '..####..', + '..####..', + '########', + '.######.', + '..####..', + '..#..#..', + '.#....#.', + '#......#', + ]), + m('bell', [ + '...##...', + '...##...', + '..####..', + '.######.', + '.######.', + '########', + '########', + '...oo...', + ]), + m('heart', [ + '.#....#.', + '########', + '########', + '########', + '.######.', + '..####..', + '...##...', + '........', + ]), + m('mitten', [ + '..####..', + '.######.', + '#######.', + '######..', + '######..', + '.######.', + '.######.', + '........', + ]), + m('stocking', [ + '..####..', + '..####..', + '..####..', + '..####..', + '..#####.', + '.#######', + '########', + '#####...', + ]), +]; + +// Small 6x6 snowflake for the sleeves. +export const SLEEVE_MOTIF: Motif = m('flake6', [ + '#.##.#', + '.####.', + '######', + '######', + '.####.', + '#.##.#', +]); diff --git a/src/palettes.ts b/src/palettes.ts new file mode 100644 index 0000000..c5048f7 --- /dev/null +++ b/src/palettes.ts @@ -0,0 +1,109 @@ +// Yarn palettes. clash = how embarrassing the palette is by itself (0..100). + +export interface Palette { + name: string; + clash: number; + body: string; // main sweater color + colors: string[]; // motif / band colors +} + +export const PALETTES: Palette[] = [ + { + name: 'Sleigh Crash', + clash: 70, + body: '#b3121f', + colors: ['#1e7d32', '#f4c430', '#ffffff', '#ff5fa2'], + }, + { + name: 'Eggnog Nightmare', + clash: 85, + body: '#f3e3b8', + colors: ['#39d353', '#ff2f92', '#ff7b00', '#26c6da'], + }, + { + name: 'Radioactive Pine', + clash: 92, + body: '#2fbf3f', + colors: ['#7b2ff7', '#ff1744', '#ffe600', '#00e5ff'], + }, + { + name: 'Tinsel Overload', + clash: 65, + body: '#1c1c1c', + colors: ['#ffd700', '#e91e63', '#00bcd4', '#ff5252'], + }, + { + name: 'Grinch Sick', + clash: 75, + body: '#43a047', + colors: ['#f06292', '#ba68c8', '#ffee58', '#4fc3f7'], + }, + { + name: 'Candy Cane Vomit', + clash: 80, + body: '#ff8fa3', + colors: ['#d90429', '#ffffff', '#80ed99', '#ffd60a'], + }, + { + name: 'Nordic Normie', + clash: 28, + body: '#274b7a', + colors: ['#e8e8e8', '#c0392b', '#f1c40f', '#7fb3d5'], + }, + { + name: 'Reindeer Roadkill', + clash: 88, + body: '#6d4c41', + colors: ['#ffeb3b', '#e53935', '#4caf50', '#ff9800'], + }, +]; + +const PREFIX = [ + 'The ', + "Aunt Helga's ", + "Grandpa Ole's ", + "Cousin Kim's ", + 'The Office Party ', + 'Christmas 1987 ', + "Mom's ", +]; +const ADJ = [ + 'Eggnog-Soaked ', + 'Tinsel-Loaded ', + 'Radioactive ', + 'Cursed ', + 'Maximum ', + 'Aggressively Festive ', + 'Glitter-Bombed ', + 'Sleigh-Chasing ', + 'Mulled-Wine ', + 'Ginger-Infused ', +]; +const NOUN = [ + 'Disaster', + 'Nightmare', + 'Menace', + 'Warcrime', + 'Masterpiece', + 'Catastrophe', + 'Legend', + 'Special', + 'Tragedy', + 'Showstopper', +]; + +export const pick = (rng: () => number, arr: readonly T[]): T => + arr[Math.floor(rng() * arr.length)]!; + +export function sweaterName(rng: () => number): string { + return pick(rng, PREFIX) + pick(rng, ADJ) + pick(rng, NOUN); +} + +export function embarrassmentLabel(score: number): string { + if (score < 20) return 'Potentially office-safe'; + if (score < 40) return 'Mildly festive'; + if (score < 60) return 'Aunt-approved'; + if (score < 80) return 'Family intervention needed'; + if (score < 95) return 'Documented war crime'; + return 'Nuclear'; +} diff --git a/src/style.css b/src/style.css new file mode 100644 index 0000000..176aa60 --- /dev/null +++ b/src/style.css @@ -0,0 +1,231 @@ +:root { + color-scheme: dark; + --bg: #14181f; + --card: #1d232e; + --line: #2c3542; + --text: #e8e2d5; + --dim: #9aa4b2; + --accent: #e0b64f; +} + +* { + box-sizing: border-box; +} + +body { + margin: 0; + min-height: 100vh; + background: + radial-gradient(1200px 600px at 70% -10%, #1f2a3a 0%, transparent 60%), + var(--bg); + color: var(--text); + font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif; +} + +.wrap { + max-width: 1150px; + margin: 0 auto; + padding: 0.9rem 1.25rem 1rem; +} + +header h1 { + margin: 0; + font-size: 1.55rem; + letter-spacing: 0.01em; +} + +header .sub { + margin: 0.15rem 0 0; + color: var(--dim); + font-size: 0.9rem; +} + +.layout { + display: flex; + gap: 1.25rem; + margin-top: 0.8rem; + align-items: flex-start; +} + +.stage { + flex: 1 1 auto; + background: + radial-gradient(420px 320px at 50% 42%, rgba(224, 182, 79, 0.09), transparent 70%), + var(--card); + border: 1px solid var(--line); + border-radius: 14px; + display: flex; + align-items: center; + justify-content: center; + padding: 0.75rem; + min-height: 480px; +} + +canvas { + max-width: 100%; + max-height: 70vh; + height: auto; + filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.45)); +} + +.panel { + flex: 0 0 320px; + display: flex; + flex-direction: column; + gap: 0.7rem; +} + +.name-card { + background: var(--card); + border: 1px solid var(--line); + border-radius: 14px; + padding: 0.75rem 0.9rem; +} + +.sweater-name { + font-size: 1.15rem; + font-weight: 700; + color: var(--accent); + min-height: 1.4em; +} + +.meter-row { + display: flex; + align-items: center; + gap: 0.5rem; + margin-top: 0.45rem; +} + +.meter-label { + font-size: 0.72rem; + text-transform: uppercase; + letter-spacing: 0.08em; + color: var(--dim); + white-space: nowrap; +} + +.meter { + flex: 1; + height: 10px; + background: #0e1218; + border-radius: 6px; + overflow: hidden; +} + +.meter-fill { + height: 100%; + width: 0; + border-radius: 6px; + transition: width 0.35s ease; +} + +.meter-score { + font-variant-numeric: tabular-nums; + font-weight: 700; + min-width: 2.2em; + text-align: right; +} + +.meter-verdict { + margin-top: 0.3rem; + font-size: 0.85rem; + color: var(--dim); + font-style: italic; +} + +.palette-line { + margin-top: 0.45rem; + font-size: 0.8rem; + color: var(--dim); +} + +.controls { + background: var(--card); + border: 1px solid var(--line); + border-radius: 14px; + padding: 0.75rem 0.9rem; + display: flex; + flex-direction: column; + gap: 0.55rem; +} + +button { + font: inherit; + font-weight: 600; + color: #1a1408; + background: linear-gradient(180deg, #f0c964, #d9a83e); + border: 0; + border-radius: 9px; + padding: 0.45rem 0.9rem; + cursor: pointer; +} + +button:hover { + filter: brightness(1.08); +} + +button.big { + font-size: 1rem; + padding: 0.6rem 0.9rem; +} + +button:not(.big) { + background: #2c3542; + color: var(--text); +} + +.ctl { + display: flex; + flex-direction: column; + gap: 0.25rem; + font-size: 0.82rem; + color: var(--dim); +} + +.ctl b { + color: var(--text); +} + +input[type='range'] { + accent-color: var(--accent); +} + +select, +input[type='number'] { + font: inherit; + background: #0e1218; + color: var(--text); + border: 1px solid var(--line); + border-radius: 8px; + padding: 0.35rem 0.55rem; +} + +.seed-row { + display: flex; + gap: 0.4rem; +} + +.seed-row input { + flex: 1; + min-width: 0; +} + +.seed-row button { + padding: 0.4rem 0.6rem; +} + +.hint { + margin: 0; + font-size: 0.75rem; + color: var(--dim); +} + +@media (max-width: 860px) { + .layout { + flex-direction: column; + } + .panel { + flex: 1 1 auto; + width: 100%; + } +} diff --git a/src/sweater.ts b/src/sweater.ts new file mode 100644 index 0000000..db5c076 --- /dev/null +++ b/src/sweater.ts @@ -0,0 +1,364 @@ +// Procedural ugly-sweater generation and canvas rendering. +// The sweater is a grid of "stitches"; bands of cross-stitch motifs are knitted +// onto a flat-lay silhouette. Everything is deterministic from the seed. + +import { MOTIFS, SLEEVE_MOTIF, type Motif } from './motifs'; +import { PALETTES, type Palette, embarrassmentLabel, pick, sweaterName } from './palettes'; + +export const GRID_W = 52; +export const GRID_H = 46; +const CELL = 12; + +export interface SweaterConfig { + seed: number; + paletteId: number; // -1 = surprise me (derived from seed) + ugliness: number; // 0..100 +} + +export interface Sweater { + config: SweaterConfig; + palette: Palette; + name: string; + embarrassment: number; + label: string; + cells: (string | null)[][]; // [row][col] stitch color, null = not sweater +} + +// ---- seeded rng ---- +function mulberry32(seed: number): () => number { + let a = seed >>> 0; + return () => { + a |= 0; + a = (a + 0x6d2b79f5) | 0; + let t = Math.imul(a ^ (a >>> 15), 1 | a); + t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t; + return ((t ^ (t >>> 14)) >>> 0) / 4294967296; + }; +} + +// deterministic per-cell noise for stitch shading +function hash2(seed: number, x: number, y: number): number { + let h = seed ^ Math.imul(x, 0x9e3779b1) ^ Math.imul(y, 0x85ebca6b); + h = Math.imul(h ^ (h >>> 13), 0xc2b2ae35); + h ^= h >>> 16; + return (h >>> 0) / 4294967296; +} + +// ---- color helpers ---- +const hexToRgb = (hex: string): [number, number, number] => [ + parseInt(hex.slice(1, 3), 16), + parseInt(hex.slice(3, 5), 16), + parseInt(hex.slice(5, 7), 16), +]; +const rgbToHex = (r: number, g: number, b: number): string => + '#' + + [r, g, b] + .map((v) => Math.max(0, Math.min(255, Math.round(v))).toString(16).padStart(2, '0')) + .join(''); +const shade = (hex: string, f: number): string => { + const [r, g, b] = hexToRgb(hex); + return rgbToHex(r * f, g * f, b * f); +}; + +// ---- silhouette ---- +// Regions: 0 = empty, 1 = body, 2 = sleeve, 3 = rib (collar/cuffs/hem) +function regionOf(r: number, c: number): number { + // body rows 4..43, cols 14..37 + if (r >= 4 && r <= 43 && c >= 14 && c <= 37) { + // neck hole: symmetric rounded scoop + if ((r === 4 || r === 7) && c >= 23 && c <= 28) return 0; + if ((r === 5 || r === 6) && c >= 22 && c <= 29) return 0; + if (r <= 8) return 3; // collar rib + if (r >= 41) return 3; // hem rib + return 1; + } + // sleeves rows 4..22, diagonal outer edge + if (r >= 4 && r <= 22) { + const out = Math.max(0, 12 - (r - 4)); // left sleeve outer col + if (c >= out && c <= 13) return r >= 21 ? 3 : 2; + const outR = Math.min(GRID_W - 1, 39 + (r - 4)); // right sleeve outer col + if (c >= 38 && c <= outR) return r >= 21 ? 3 : 2; + } + return 0; +} + +// ---- band patterns ---- +type BandFn = ( + put: (r: number, c: number, color: string) => void, + r0: number, + r1: number, + c0: number, + c1: number, + cols: string[], + rng: () => number, +) => void; + +const zigzag: BandFn = (put, r0, r1, c0, c1, cols) => { + const h = r1 - r0 + 1; + const amp = Math.max(1, Math.floor((h - 1) / 2)); + const mid = r0 + amp; + const period = 2 * amp * 2; + for (let c = c0; c <= c1; c++) { + const t = (c - c0) % period; + const dy = t < period / 2 ? t : period - t; // triangle 0..amp + put(mid - amp + dy, c, cols[0]!); + if (mid - amp + dy + 1 <= r1) put(mid - amp + dy + 1, c, cols[1]!); + } +}; + +const dots: BandFn = (put, r0, r1, c0, c1, cols) => { + const mid = Math.floor((r0 + r1) / 2); + for (let c = c0; c <= c1; c++) { + if ((c - c0) % 2 === 0) put(mid, c, cols[0]!); + else if (r0 !== mid) put(r0, c, cols[1]!); + } +}; + +const diamonds: BandFn = (put, r0, r1, c0, c1, cols) => { + const mid = Math.floor((r0 + r1) / 2); + for (let c = c0; c <= c1; c++) { + for (let r = r0; r <= r1; r++) { + const d = Math.abs(((c - c0) % 6) - 3) + Math.abs(r - mid); + if (d <= 1) put(r, c, cols[0]!); + else if (d === 2) put(r, c, cols[1]!); + } + } +}; + +const stripes: BandFn = (put, r0, r1, c0, c1, cols) => { + for (let r = r0; r <= r1; r++) { + const col = (r - r0) % 2 === 0 ? cols[0]! : cols[1]!; + for (let c = c0; c <= c1; c++) if ((c + r) % 2 === 0) put(r, c, col); + } +}; + +const crosses: BandFn = (put, r0, r1, c0, c1, cols) => { + const mid = Math.floor((r0 + r1) / 2); + for (let c = c0; c <= c1; c++) { + if ((c - c0) % 4 === 0) { + put(mid, c, cols[0]!); + if (mid - 1 >= r0) put(mid - 1, c, cols[0]!); + if (mid + 1 <= r1) put(mid + 1, c, cols[0]!); + put(mid, Math.min(c1, c + 1), cols[0]!); + if (c > c0) put(mid, c - 1, cols[0]!); + } else if ((c - c0) % 4 === 2) { + put(r0, c, cols[1]!); + if (r1 !== r0) put(r1, c, cols[1]!); + } + } +}; + +const BANDS: BandFn[] = [zigzag, dots, diamonds, stripes, crosses]; + +// ---- generation ---- +function resolvePalette(cfg: SweaterConfig): Palette { + if (cfg.paletteId >= 0 && cfg.paletteId < PALETTES.length) return PALETTES[cfg.paletteId]!; + return PALETTES[Math.abs(cfg.seed) % PALETTES.length]!; +} + +export function generate(cfg: SweaterConfig): Sweater { + const rng = mulberry32(cfg.seed); + const palette = resolvePalette(cfg); + const u = cfg.ugliness / 100; + + const cells: (string | null)[][] = []; + const regions: number[][] = []; + for (let r = 0; r < GRID_H; r++) { + cells.push(new Array(GRID_W).fill(null)); + regions.push(new Array(GRID_W).fill(0)); + for (let c = 0; c < GRID_W; c++) regions[r]![c] = regionOf(r, c); + } + const put = (r: number, c: number, color: string): void => { + if (r < 0 || r >= GRID_H || c < 0 || c >= GRID_W) return; + const reg = regions[r]![c]; + // patterns paint over the base fill but never over ribbing or empty space + if (reg === 1 || reg === 2) cells[r]![c] = color; + }; + + const ribLight = shade(palette.body, 1.25); + const ribDark = shade(palette.body, 0.72); + const bodyDark = shade(palette.body, 0.88); + + // base fill + for (let r = 0; r < GRID_H; r++) + for (let c = 0; c < GRID_W; c++) + if (regions[r]![c] === 1 || regions[r]![c] === 2) cells[r]![c] = palette.body; + + // ribbing: vertical ribs on cuffs/hem, horizontal rows around the collar + for (let r = 0; r < GRID_H; r++) + for (let c = 0; c < GRID_W; c++) + if (regions[r]![c] === 3) + cells[r]![c] = r <= 8 ? (r % 2 === 0 ? ribLight : ribDark) : c % 2 === 0 ? ribLight : ribDark; + + // how many colors are in play scales with ugliness + const colorCount = 2 + Math.round(u * 2); // 2..4 + const colors = palette.colors.slice(0, colorCount); + const pool = MOTIFS.filter((mo) => (u < 0.35 ? mo.tame : true)); + + const usedColors = new Set(); + const band = ( + fn: BandFn, + r0: number, + r1: number, + c0: number, + c1: number, + cols: string[], + ): void => { + fn(put, r0, r1, c0, c1, cols, rng); + for (const col of cols) usedColors.add(col); + }; + + const motifBand = ( + motif: Motif, + r0: number, + r1: number, + c0: number, + c1: number, + motifColor: string, + secColor: string, + altBg: string | null, + forcedRepeats?: number, + ): void => { + const width = c1 - c0 + 1; + // +2 gap so motifs never merge into a solid panel + const repeats = forcedRepeats ?? Math.max(1, Math.round(width / (motif.w + 2))); + const step = width / repeats; + for (let k = 0; k < repeats; k++) { + const cx = Math.round(c0 + k * step + (step - motif.w) / 2); + if (altBg !== null) { + for (let r = r0; r <= r1; r++) + for (let c = cx - 1; c <= cx + motif.w; c++) + if (regions[r]![c] === 1 || regions[r]![c] === 2) cells[r]![c] = altBg; + } + for (let dy = 0; dy < motif.h; dy++) + for (let dx = 0; dx < motif.w; dx++) { + const ch = motif.rows[dy]![dx]; + if (ch === '#') put(r0 + dy, cx + dx, motifColor); + else if (ch === 'o') put(r0 + dy, cx + dx, secColor); + } + } + usedColors.add(motifColor); + if (altBg !== null) usedColors.add(altBg); + }; + + // pick band content + const shuffled = [...pool].sort(() => rng() - 0.5); + const motifA = shuffled[0]!; + const motifB = shuffled[1 % shuffled.length]!; + const motifC = u > 0.5 ? shuffled[2 % shuffled.length]! : motifA; + const band1 = BANDS[Math.floor(rng() * BANDS.length)]!; + const band2 = BANDS[Math.floor(rng() * BANDS.length)]!; + const yokeBand = u > 0.4 ? band1 : zigzag; + + const cA = colors[0]!; + const cB = colors[1 % colors.length]!; + const cC = colors[2 % colors.length]!; + const cD = colors[3 % colors.length]!; + const altBg = u > 0.45 ? colors[Math.floor(rng() * colors.length)]! : null; + + // body layout: yoke 9..11, A 12..19, band1 20..22, B 23..30, band2 31..32, C 33..40 + yokeBand(put, 9, 11, 14, 37, [cB, bodyDark], rng); + motifBand(motifA, 12, 19, 14, 37, cA, cB, altBg); + band(band1, 20, 22, 14, 37, [cC, cD]); + motifBand(motifB, 23, 30, 14, 37, cB, cC, altBg); + band(dots, 31, 32, 14, 37, [cD, cA]); + motifBand(motifC, 33, 40, 14, 37, cC, cD, altBg); + + // sleeves: zigzag 9..11, flake band 12..17, dots 18..20 + for (const [c0, c1] of [ + [0, 13], + [38, GRID_W - 1], + ] as const) { + zigzag(put, 9, 11, c0, c1, [cC, bodyDark], rng); + motifBand(SLEEVE_MOTIF, 12, 17, c0, c1, cA, cB, null, 1); + dots(put, 18, 20, c0, c1, [cD, bodyDark], rng); + } + + // name + embarrassment score + const name = sweaterName(rng); + const distinct = usedColors.size; + const score = Math.max( + 4, + Math.min( + 100, + Math.round( + palette.clash * (0.55 + 0.45 * u) + + distinct * 3 + + (altBg !== null ? 6 : 0) + + rng() * 8, + ), + ), + ); + + return { + config: cfg, + palette, + name, + embarrassment: score, + label: embarrassmentLabel(score), + cells, + }; +} + +// ---- rendering ---- +export function render(canvas: HTMLCanvasElement, sweater: Sweater): void { + const dpr = Math.min(2, window.devicePixelRatio || 1); + canvas.width = GRID_W * CELL * dpr; + canvas.height = GRID_H * CELL * dpr; + const ctx = canvas.getContext('2d')!; + ctx.scale(dpr, dpr); + ctx.clearRect(0, 0, GRID_W * CELL, GRID_H * CELL); + + const seed = sweater.config.seed >>> 0; + const noise = 0.05 + (sweater.config.ugliness / 100) * 0.05; + + for (let r = 0; r < GRID_H; r++) { + for (let c = 0; c < GRID_W; c++) { + const color = sweater.cells[r]?.[c] ?? null; + if (color === null) continue; + const x = c * CELL; + const y = r * CELL; + // per-stitch brightness jitter + const j = 1 + (hash2(seed, c, r) - 0.5) * 2 * noise; + const base = shade(color, j); + ctx.fillStyle = base; + ctx.fillRect(x, y, CELL, CELL); + // knit chevron: dark V + light highlight (subtle so motifs stay readable) + ctx.strokeStyle = shade(base, 0.86); + ctx.lineWidth = 1.6; + ctx.beginPath(); + ctx.moveTo(x + 1, y + 2.5); + ctx.lineTo(x + CELL / 2, y + CELL - 2); + ctx.lineTo(x + CELL - 1, y + 2.5); + ctx.stroke(); + ctx.strokeStyle = shade(base, 1.12); + ctx.lineWidth = 1; + ctx.beginPath(); + ctx.moveTo(x + 1, y + 1.5); + ctx.lineTo(x + CELL / 2, y + CELL - 3); + ctx.stroke(); + } + } + + // subtle outline around the silhouette + ctx.strokeStyle = 'rgba(0,0,0,0.35)'; + ctx.lineWidth = 1; + for (let r = 0; r < GRID_H; r++) { + for (let c = 0; c < GRID_W; c++) { + if (sweater.cells[r]![c] === null) continue; + const x = c * CELL; + const y = r * CELL; + const edge = (dr: number, dc: number): boolean => { + const rr = r + dr; + const cc = c + dc; + return rr < 0 || rr >= GRID_H || cc < 0 || cc >= GRID_W || sweater.cells[rr]![cc] === null; + }; + ctx.beginPath(); + if (edge(-1, 0)) { ctx.moveTo(x, y); ctx.lineTo(x + CELL, y); } + if (edge(1, 0)) { ctx.moveTo(x, y + CELL); ctx.lineTo(x + CELL, y + CELL); } + if (edge(0, -1)) { ctx.moveTo(x, y); ctx.lineTo(x, y + CELL); } + if (edge(0, 1)) { ctx.moveTo(x + CELL, y); ctx.lineTo(x + CELL, y + CELL); } + ctx.stroke(); + } + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..8b42ef2 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "ES2023", + "module": "ESNext", + "moduleResolution": "bundler", + "lib": ["ES2023", "DOM", "DOM.Iterable"], + "types": ["vite/client"], + "strict": true, + "noUncheckedIndexedAccess": true, + "verbatimModuleSyntax": true, + "skipLibCheck": true, + "noEmit": true + }, + "include": ["src"] +} diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..08e54d3 --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,6 @@ +import { defineConfig } from 'vite'; + +export default defineConfig({ + // Relative links, so the build works under https://.github.io// whatever the repository is called. + base: './', +});