diff --git a/demo.css b/demo.css index ec1b14f..d495609 100644 --- a/demo.css +++ b/demo.css @@ -249,6 +249,7 @@ body { font-family: 'Inter'; font-size: 18px; font-weight: 540; + line-height: 1.45; } @media (max-width: 500px) { html, @@ -267,20 +268,16 @@ canvas { height: 100vh; } image-refractor { - width: 100vmin; - height: 100vmin; -} -@media (max-width: 500px) { - image-refractor { - width: 120vmin; - height: 120vmin; - } + width: 94vmin; + height: 94vmin; + border-radius: 15px; + overflow: hidden; } main { position: absolute; display: flex; flex-direction: column; - gap: 1rem; + gap: 2rem; inset: 0; padding: 1.7rem 2rem; } @@ -291,10 +288,13 @@ h1 { margin: 0; margin-left: -2px; font-size: 2.65rem; - font-weight: 780; + font-weight: 760; letter-spacing: -0.035em; line-height: 1; } +p { + margin: 0; +} a { color: inherit; text-decoration: none; @@ -303,27 +303,45 @@ a { a:hover { color: hsl(215, 12%, 30%); } +summary { + cursor: pointer; +} +details > div { + display: flex; + flex-direction: column; + gap: 2rem; + margin-top: 2rem; +} label { - color: hsl(215, 12%, 30%); + margin-bottom: 0.5rem; } .presets { display: flex; - gap: 0.5rem; - margin-top: 0.3rem; + flex-direction: column; + align-items: start; } +swap-image, refractor-preset { color: hsl(215, 12%, 30%); cursor: pointer; transition: color 0.2s; } +swap-image:before, +refractor-preset:before { + content: '○'; + padding-right: 0.5em; +} +swap-image.active, refractor-preset.active { - text-decoration: underline; - text-underline-offset: 4px; color: #ffffff; } +swap-image.active:before, +refractor-preset.active:before { + content: '●'; +} .github { position: fixed; - top: 1.8rem; - right: 1.8rem; + top: 2rem; + right: 2rem; } diff --git a/demo.js b/demo.js index 982bbba..acf0fc8 100644 --- a/demo.js +++ b/demo.js @@ -1 +1 @@ -(()=>{var t={908:(t,e,i)=>{var r;r="undefined"!=typeof window?window:void 0!==i.g?i.g:"undefined"!=typeof self?self:{},t.exports=r},376:t=>{t.exports=function(t){if(!t)return!1;var i=e.call(t);return"[object Function]"===i||"function"==typeof t&&"[object RegExp]"!==i||"undefined"!=typeof window&&(t===window.setTimeout||t===window.alert||t===window.confirm||t===window.prompt)};var e=Object.prototype.toString},947:t=>{var e=function(t){return t.replace(/^\s+|\s+$/g,"")};t.exports=function(t){if(!t)return{};for(var i,r={},s=e(t).split("\n"),n=0;n{"use strict";var r=i(908),s=i(376),n=i(947),a=i(529);function o(t,e,i){var r=t;return s(e)?(i=e,"string"==typeof t&&(r={uri:t})):r=a(e,{uri:t}),r.callback=i,r}function h(t,e,i){return l(e=o(t,e,i))}function l(t){if(void 0===t.callback)throw new Error("callback argument missing");var e=!1,i=function(i,r,s){e||(e=!0,t.callback(i,r,s))};function r(){var t=void 0;if(t=u.response?u.response:u.responseText||function(t){try{if("document"===t.responseType)return t.responseXML;var e=t.responseXML&&"parsererror"===t.responseXML.documentElement.nodeName;if(""===t.responseType&&!e)return t.responseXML}catch(t){}return null}(u),T)try{t=JSON.parse(t)}catch(t){}return t}function s(t){return clearTimeout(d),t instanceof Error||(t=new Error(""+(t||"Unknown XMLHttpRequest Error"))),t.statusCode=0,i(t,p)}function a(){if(!l){var e;clearTimeout(d),e=t.useXDR&&void 0===u.status?200:1223===u.status?204:u.status;var s=p,a=null;return 0!==e?(s={body:r(),statusCode:e,method:f,headers:{},url:g,rawRequest:u},u.getAllResponseHeaders&&(s.headers=n(u.getAllResponseHeaders()))):a=new Error("Internal XMLHttpRequest Error"),i(a,s,s.body)}}var o,l,u=t.xhr||null;u||(u=t.cors||t.useXDR?new h.XDomainRequest:new h.XMLHttpRequest);var d,g=u.url=t.uri||t.url,f=u.method=t.method||"GET",c=t.body||t.data,m=u.headers=t.headers||{},E=!!t.sync,T=!1,p={body:void 0,headers:{},statusCode:0,method:f,url:g,rawRequest:u};if("json"in t&&!1!==t.json&&(T=!0,m.accept||m.Accept||(m.Accept="application/json"),"GET"!==f&&"HEAD"!==f&&(m["content-type"]||m["Content-Type"]||(m["Content-Type"]="application/json"),c=JSON.stringify(!0===t.json?c:t.json))),u.onreadystatechange=function(){4===u.readyState&&setTimeout(a,0)},u.onload=a,u.onerror=s,u.onprogress=function(){},u.onabort=function(){l=!0},u.ontimeout=s,u.open(f,g,!E,t.username,t.password),E||(u.withCredentials=!!t.withCredentials),!E&&t.timeout>0&&(d=setTimeout((function(){if(!l){l=!0,u.abort("timeout");var t=new Error("XMLHttpRequest timeout");t.code="ETIMEDOUT",s(t)}}),t.timeout)),u.setRequestHeader)for(o in m)m.hasOwnProperty(o)&&u.setRequestHeader(o,m[o]);else if(t.headers&&!function(t){for(var e in t)if(t.hasOwnProperty(e))return!1;return!0}(t.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in t&&(u.responseType=t.responseType),"beforeSend"in t&&"function"==typeof t.beforeSend&&t.beforeSend(u),u.send(c||null),u}t.exports=h,t.exports.default=h,h.XMLHttpRequest=r.XMLHttpRequest||function(){},h.XDomainRequest="withCredentials"in new h.XMLHttpRequest?h.XMLHttpRequest:r.XDomainRequest,function(t,e){for(var i=0;i{t.exports=function(){for(var t={},i=0;i{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{"use strict";class t extends HTMLElement{constructor(){super()}connectedCallback(){const t=this.getAttribute("speed")||"0.05",e=this.getAttribute("intensity")||"1.0";this.textContent=`${e}/${t}`,this.addEventListener("click",(i=>{const r=i.target;Array.from(document.querySelectorAll("refractor-preset")).forEach((t=>{t.classList.toggle("active",t===r)}));const s=document.querySelector("image-refractor"),n=document.createElement("image-refractor");n.setAttribute("width",s.getAttribute("width")),n.setAttribute("height",s.getAttribute("height")),n.setAttribute("refract",s.getAttribute("refract")),n.setAttribute("src",s.getAttribute("src")),n.setAttribute("speed",t),n.setAttribute("intensity",e),s.replaceWith(n)}))}}customElements.define("refractor-preset",t);var e=i(875),r=i.n(e);let s="";function n(t,e,i){function r(e,r){"function"==typeof i?i(e):function(e){let i=t.parentNode;i&&(i.innerHTML='\n\n
\n
\n
'+e+"
\n
\n
\n")}(r)}if(!window.WebGLRenderingContext)return r(1,'\n\tThis page requires a browser that supports WebGL.
\n\tClick here to upgrade your browser.\n'),null;let s=function(t,e){let i=["webgl","experimental-webgl"],r=null;for(var s=0;s\n\tClick here for more information.\n'),s}function a(t,e,i,r){let n=t.gl,a=n.createShader(i);return n.shaderSource(a,e),n.compileShader(a),n.getShaderParameter(a,n.COMPILE_STATUS)?a:(s=n.getShaderInfoLog(a),console.error("*** Error compiling shader "+a+":"+s),t.trigger("error",{shader:a,source:e,type:i,error:s,offset:r||0}),n.deleteShader(a),null)}function o(t,e,i,r){let n=t.gl,a=n.createProgram();for(let t=0;t=2&&n.length<=4?i.push({type:"vec"+n.length,method:n.length+"fv",name:r,value:n}):n.length>4&&i.push({type:"float[]",method:"1fv",name:r+"[0]",value:n});else if("string"==typeof n[0])i.push({type:"sampler2D",method:"1i",name:r,value:n});else if(Array.isArray(n[0])&&"number"==typeof n[0][0]){if(n[0].length>=2&&n[0].length<=4)for(s=0;s{let s,n=t.split(".").pop().toLowerCase(),a="ogv"===n||"webm"===n||"mp4"===n;a?(s=document.createElement("video"),s.autoplay=!0,s.muted=!0,setTimeout((function(){s.play()}),1),e.filtering="nearest"):s=new Image,s.onload=()=>{try{this.setElement(s,e)}catch(t){console.log(`Texture '${this.name}': failed to load url: '${this.source}'`,t,e)}i(this)},s.onerror=t=>{console.log(`Texture '${this.name}': failed to load url: '${this.source}'`,t,e),i(this)},/^((?!chrome|android).)*safari/i.test(navigator.userAgent)&&"data:"===this.source.slice(0,5)||(s.crossOrigin="anonymous"),s.src=this.source,a&&this.setElement(s,e)})),this.loading}setData(t,e,i,r={}){return this.width=t,this.height=e,this.source=i,this.sourceType="data",this.update(r),this.setFiltering(r),this.loading=Promise.resolve(this),this.loading}setElement(t,e){let i=t;if("string"==typeof t&&(t=document.querySelector(t)),t instanceof HTMLCanvasElement||t instanceof HTMLImageElement||t instanceof HTMLVideoElement)this.source=t,this.sourceType="element",t instanceof HTMLVideoElement?(this.width=this.source.videoWidth,this.height=this.source.videoHeight,t.addEventListener("canplaythrough",(()=>{this.intervalID=setInterval((()=>{this.update(e)}),15)}),!0),t.addEventListener("ended",(()=>{t.currentTime=0,t.play()}),!0)):this.update(e),this.setFiltering(e);else{let t=`the 'element' parameter (\`element: ${JSON.stringify(i)}\`) must be a CSS `;t+="selector string, or a , or