{"id":"fx-particle-reveal","name":"Particle reveal","source":"design-academy-fancy","sourceName":"Original · clean-room","repo":"SiinXu/design-academy","license":"MIT","licenseUrl":"https://github.com/SiinXu/design-academy/blob/main/LICENSE","licenseText":"MIT License\n\nCopyright (c) 2026 Incidental AI (XU SIYIN)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","original":"https://github.com/SiinXu/design-academy/blob/main/src/fancy/items/fx-particle-reveal.html","fileUrl":"https://github.com/SiinXu/design-academy/blob/main/src/fancy/items/fx-particle-reveal.html","author":"Incidental AI","authorUrl":"https://github.com/SiinXu/design-academy","category":"fancy","tags":["fancy","particles","canvas","text"],"addedAt":"2026-11-14T17:30:00Z","fancy":true,"provenance":"rewrite","inspired":{"name":"Canvas UI (particle reveal, X post #1)","url":"https://x.com/tranmautritam/status/2083121320876020223","post":"01"},"html":"<div class=\"pr\" aria-label=\"Particle reveal: dots assemble into a word and scatter from the pointer\"><canvas></canvas><p>move the pointer through the word</p></div>","css":"\n:root{--bg:#f6f4ef;--ink:#17181a;--accent:#fe3d70}\n:root[data-theme=dark]{--bg:#0b0b0d;--ink:#f3f1ec;--accent:#ff6a88}\nhtml,body{height:100%;margin:0;background:var(--bg)}\n.pr{position:relative;width:100%;height:100%;display:grid;place-items:center;overflow:hidden}\n.pr canvas{position:absolute;inset:0;width:100%;height:100%}\n.pr p{position:absolute;bottom:18px;left:0;right:0;margin:0;text-align:center;font:500 12px/1.4 system-ui,sans-serif;letter-spacing:.14em;text-transform:uppercase;color:var(--ink);opacity:.5}\n","scripted":true,"shot":{"w":640,"h":400,"stage":"dark","tone":"dark","vivid":true,"zoom":1,"mobileZoom":1},"ord":0,"newRank":320,"holder":"2026 Incidental AI (XU SIYIN)","code":"/*!\n * Particle reveal by Incidental AI — https://github.com/SiinXu/design-academy/blob/main/src/fancy/items/fx-particle-reveal.html\n * Source: https://github.com/SiinXu/design-academy/blob/main/src/fancy/items/fx-particle-reveal.html\n * License: MIT — Copyright (c) 2026 Incidental AI (XU SIYIN)\n * https://github.com/SiinXu/design-academy/blob/main/LICENSE\n *\n * MIT License\n * \n * Copyright (c) 2026 Incidental AI (XU SIYIN)\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n */\n\n<!-- HTML -->\n<div class=\"pr\" aria-label=\"Particle reveal: dots assemble into a word and scatter from the pointer\"><canvas></canvas><p>move the pointer through the word</p></div>\n\n<style>\n\n:root{--bg:#f6f4ef;--ink:#17181a;--accent:#fe3d70}\n:root[data-theme=dark]{--bg:#0b0b0d;--ink:#f3f1ec;--accent:#ff6a88}\nhtml,body{height:100%;margin:0;background:var(--bg)}\n.pr{position:relative;width:100%;height:100%;display:grid;place-items:center;overflow:hidden}\n.pr canvas{position:absolute;inset:0;width:100%;height:100%}\n.pr p{position:absolute;bottom:18px;left:0;right:0;margin:0;text-align:center;font:500 12px/1.4 system-ui,sans-serif;letter-spacing:.14em;text-transform:uppercase;color:var(--ink);opacity:.5}\n\n</style>\n\n<script>\n/* Modified by Incidental AI, 2026: quality: cap devicePixelRatio and pause rAF when the document is hidden or off-screen. */\n(function () {\n  var cap = 1.5, visible = document.visibilityState !== 'hidden', onscreen = true;\n  try {\n    var desc = Object.getOwnPropertyDescriptor(Window.prototype, 'devicePixelRatio') || Object.getOwnPropertyDescriptor(window, 'devicePixelRatio');\n    var get = desc && desc.get ? desc.get.bind(window) : function () { return cap; };\n    Object.defineProperty(window, 'devicePixelRatio', { configurable: true, get: function () { return Math.min(get() || 1, cap); } });\n  } catch (e) {}\n  document.addEventListener('visibilitychange', function () { visible = document.visibilityState !== 'hidden'; });\n  if (typeof IntersectionObserver === 'function') {\n    try {\n      var io = new IntersectionObserver(function (es) { onscreen = es.some(function (e) { return e.isIntersecting; }); }, { threshold: 0.01 });\n      io.observe(document.documentElement);\n    } catch (e) {}\n  }\n  var raf = window.requestAnimationFrame.bind(window);\n  window.requestAnimationFrame = function (cb) {\n    if (visible && onscreen) return raf(cb);\n    return raf(function tick(t) {\n      if (visible && onscreen) cb(t);\n      else raf(tick);\n    });\n  };\n})();\n\n// fx-runtime.js (sets window.FX: theme, reduced motion, render loop)\n/* Incidental AI Design Academy fx runtime (MIT). Theme from #dark/#light, reduced motion, visibility pause.\n   Small 2D canvases (≤640×640 device px, by backing size or on-screen box, when the context is created) are CPU-backed via willReadFrequently: sprite-heavy\n   components redraw many small canvases per frame, and GPU-backed readback/compositing of tiny canvases is the slow path. */\n(function(){[window.HTMLCanvasElement,window.OffscreenCanvas].forEach(function(C){if(!C)return;var g=C.prototype.getContext;C.prototype.getContext=function(t,o){var a=this.width*this.height;if(this.isConnected&&this.getBoundingClientRect){var r=this.getBoundingClientRect(),p=window.devicePixelRatio||1;a=Math.max(a,r.width*r.height*p*p)}if(t==='2d'&&a<=409600){var x={};if(o)for(var k in o)x[k]=o[k];if(x.willReadFrequently===undefined)x.willReadFrequently=true;return g.call(this,t,x)}return g.apply(this,arguments)}})})();\n(function(){var d=document.documentElement,q=function(){var h=location.hash.slice(1);if(h==='dark'||h==='light')d.dataset.theme=h;else if(!d.dataset.theme)d.dataset.theme=d.getAttribute('data-default')||'dark'};q();addEventListener('hashchange',function(){q();dispatchEvent(new Event('fx-theme'))});\nvar m=matchMedia('(prefers-reduced-motion: reduce)');window.FX={rm:m.matches,dark:function(){return d.dataset.theme==='dark'},loop:function(f){var on=true,t0=performance.now(),id=0;function step(t){f((t-t0)/1000);if(on&&!FX.rm)id=requestAnimationFrame(step)}if(FX.rm){f(2.2);addEventListener('fx-theme',function(){f(2.2)});return}id=requestAnimationFrame(step);document.addEventListener('visibilitychange',function(){if(document.hidden){on=false;cancelAnimationFrame(id)}else if(!on){on=true;id=requestAnimationFrame(step)}})}};\nm.addEventListener&&m.addEventListener('change',function(){location.reload()})})();\n\n// effect\n(function(){var c=document.querySelector('.pr canvas'),x=c.getContext('2d'),W,H,P=[],dpr=Math.min(devicePixelRatio||1,2),mx=-1e4,my=-1e4,word='Academy';\nfunction css(n){return getComputedStyle(document.documentElement).getPropertyValue(n).trim()}\nfunction build(){W=c.clientWidth;H=c.clientHeight;if(!W||!H){P=[];return}c.width=W*dpr;c.height=H*dpr;var o=document.createElement('canvas'),ox=o.getContext('2d');o.width=W;o.height=H;var F=function(z){return 'italic 400 '+z+'px Georgia,\"Times New Roman\",serif'};ox.font=F(100);var fs=Math.min(H/2.6,100*W*.88/ox.measureText(word).width);ox.font=F(fs);ox.textAlign='center';ox.textBaseline='middle';ox.fillText(word,W/2,H/2-8);var d=ox.getImageData(0,0,W,H).data,g=Math.max(3,Math.round(W/170)),old=P;P=[];\nfor(var y=0;y<H;y+=g)for(var i=0;i<W;i+=g)if(d[(y*W+i)*4+3]>128){var p=old[P.length]||{x:Math.random()*W,y:Math.random()*H,vx:0,vy:0};p.tx=i;p.ty=y;p.r=g*.42*(0.7+Math.random()*.6);p.h=Math.random();P.push(p)}}\nfunction draw(t){x.setTransform(dpr,0,0,dpr,0,0);x.clearRect(0,0,W,H);var ink=css('--ink'),ac=css('--accent');\nfor(var k=0;k<P.length;k++){var p=P[k],dx=p.x-mx,dy=p.y-my,d2=dx*dx+dy*dy,R=46*46;if(d2<R){var f=(1-d2/R)*5;p.vx+=dx/Math.sqrt(d2+1)*f;p.vy+=dy/Math.sqrt(d2+1)*f}\np.vx+=(p.tx-p.x)*.06;p.vy+=(p.ty-p.y)*.06;p.vx*=.82;p.vy*=.82;p.x+=p.vx;p.y+=p.vy;if(FX.rm){p.x=p.tx;p.y=p.ty}\nvar sp=Math.min(1,Math.hypot(p.vx,p.vy)/6);x.fillStyle=sp>.15||p.h>.93?ac:ink;x.globalAlpha=.55+.45*(1-sp);x.beginPath();x.arc(p.x,p.y,p.r,0,6.283);x.fill()}x.globalAlpha=1}\nbuild();addEventListener('resize',build);c.addEventListener('pointermove',function(e){var r=c.getBoundingClientRect();mx=e.clientX-r.left;my=e.clientY-r.top});c.addEventListener('pointerleave',function(){mx=my=-1e4});\nvar auto=0;FX.loop(function(t){if(mx<-1e3&&!FX.rm){auto=t;var a=t*.45;mx=W/2+Math.sin(a)*W*.38;my=H/2-8+Math.sin(a*2.3)*H*.05;draw(t);mx=my=-1e4}else draw(t)});})();\n</script>\n","prompt":"Build a \"Particle reveal\" component in plain HTML, CSS and JavaScript (no framework). The word is drawn by thousands of dots that spring back after the pointer pushes them, so the text feels alive but stays readable. Use it for: A hero word, a brand name or a launch page headline. Expose these controls: Change the word, the dot gap, the push radius and the spring strength. Support light and dark themes, respect prefers-reduced-motion with a still frame, keep text readable and controls keyboard accessible. Write original code; do not copy from paid or restricted component libraries."}