~thewhodidthis/dirtfoulandbooty

f174a16b0654f591f034c51e795294b6884c8a78 — thewhodidthis a month ago 2b34ac0
js: fix for deno lint, up deps, rebuild
2 files changed, 6 insertions(+), 17 deletions(-)

M bundle.js
M client.js
M bundle.js => bundle.js +2 -12
@@ 1,21 1,11 @@
(()=>{var T=s=>{if(s===void 0||typeof s!="function")throw new TypeError("Missing callback");let t=r=>window.requestAnimationFrame(r),e,n=r=>{s(r,e),e&&(e=t(n))},o=()=>(e=e||t(n),e),c=()=>(e=e&&window.cancelAnimationFrame(e),e);return{start:o,stop:c,play:o,pause:c}},d=(s={},...t)=>t.reduce((e,n)=>{let o=s[n];return o===void 0?e:o},()=>{}),F=(s=document)=>d(s,"webkitFullscreenElement","mozFullScreenElement","msFullscreenElement","fullscreenElement"),C=(s=document.body)=>d(s,"webkitRequestFullScreen","mozRequestFullScreen","msRequestFullscreen","requestFullscreen").call(s),k=(s=document)=>d(s,"webkitExitFullscreen","mozCancelFullScreen","msExitFullscreen","exitFullscreen").call(s),a=s=>F()!==null?k():C(s);a.state=F;a.enter=C;a.leave=k;var A=class extends HTMLElement{constructor(){super();this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(document.createElement("slot"))}connectedCallback(){this.isConnected&&this.firstElementChild&&this.addEventListener("click",()=>{a(this.firstElementChild)})}},I=class extends HTMLElement{constructor(){super();let t=document.createRange().createContextualFragment(`
(()=>{var T=s=>{if(s===void 0||typeof s!="function")throw new TypeError("Missing callback");let t=c=>window.requestAnimationFrame(c),e,n=c=>{s(c,e),e&&(e=t(n))},r=()=>(e=e||t(n),e),o=()=>(e=e&&window.cancelAnimationFrame(e),e);return{start:r,stop:o,play:r,pause:o}},h=(s={},...t)=>t.reduce((e,n)=>{let r=s[n];return r===void 0?e:r},()=>{}),F=(s=document)=>h(s,"webkitFullscreenElement","mozFullScreenElement","msFullscreenElement","fullscreenElement"),k=(s=document.body)=>h(s,"webkitRequestFullScreen","mozRequestFullScreen","msRequestFullscreen","requestFullscreen").call(s),C=(s=document)=>h(s,"webkitExitFullscreen","mozCancelFullScreen","msExitFullscreen","exitFullscreen").call(s),a=s=>F()!==null?C():k(s);a.state=F;a.enter=k;a.leave=C;var A=class extends HTMLElement{constructor(){super();this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(document.createElement("slot"))}connectedCallback(){this.isConnected&&this.firstElementChild&&this.addEventListener("click",()=>{a(this.firstElementChild)})}},q=class extends HTMLElement{constructor(){super();let t=document.createRange().createContextualFragment(`
      <style>
        :host {
          bottom: 0;
          display: block;
          font-size: 0.75rem;
          height: 0;
          left: 0;
          line-height: 1.25;
          margin: auto;
          position: absolute;
          right: 0;
          text-align: center;
          top: 0;
        }
        :host([hidden]) {
          display: none;
        }
      </style>
      <slot></slot>
    `);this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(t)}static get observedAttributes(){return["flash","ready"]}get flash(){return this.getAttribute("flash")}set flash(t){this.setAttribute("flash",t)}get ready(){return this.getAttribute("ready")}set ready(t){this.setAttribute("ready",t)}get timeout(){let t=this.hasAttribute("timeout")?this.getAttribute("timeout"):1500;return parseInt(t,10)}set timeout(t){Number.isNaN(t)||this.setAttribute("timeout",t)}attributeChangedCallback(t,e,n){switch(t){case"ready":{if(n!=="null"){let o=new Event("ready");this.innerText="",this.dispatchEvent(o)}break}case"flash":{let o=setTimeout(()=>{clearTimeout(o),this.ready=!0},this.timeout);this.innerText=n,this.ready=null;break}}}},q=(s,t,e,n,o,c)=>{let r=s.canvas||s,b=t.canvas||t,y=e||0,E=n||0,x=o||0,v=c||0,[l,u]=[r.width-y,r.height-E],w=b.context||b.getContext("2d");w.clearRect(x,v,l,u),w.drawImage(r,y,E,l,u,x,v,l,u)},h=s=>({get context(){return this.canvas.getContext("2d")},canvas:s,source(t,e,n){return q(t,this.context,e,n),this},target(t,e,n){return q(this.context,t,0,0,e,n),this}}),j=(s,t=s)=>{let e=document.createElement("canvas"),n=Object.assign(e,{width:s,height:t});return h(n)};"customElements"in window&&(customElements.define("just-scream",A),customElements.define("just-flash",I));var M=document.getElementById("figure"),m=document.getElementById("canvas"),g=document.createElement("img"),R=h(m),i=h(m.cloneNode());M.appendChild(i.canvas);R.context.rotate(Math.PI/180);i.context.rotate(Math.PI/-90);var{width:f,height:L}=m,z=j(f,L),N=s=>{let t=s.getImageData(0,0,f,L),e=t.data;for(let n=0,o=e.length;n<o;n+=4){let c=e[n+2],r=e[n+3];e[n+2]=c>25?c:255,e[n+3]=e[n+2]===255?0:r}s.putImageData(t,0,0)},p=0,{start:P}=T((s,t)=>{if(t%15==0){let e=f*p;z.source(g,e,0).target(R).target(i),N(i.context),p+=1,p%=119}}),S=document.querySelector("just-flash");g.setAttribute("src","film.png");g.addEventListener("load",()=>{S.ready=!0});S.addEventListener("ready",P);window.addEventListener("load",()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("serviceworker.js").catch(console.log)});})();
    `);this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(t)}static get observedAttributes(){return["flash","ready"]}get flash(){return this.getAttribute("flash")}set flash(t){this.setAttribute("flash",t)}get ready(){return this.getAttribute("ready")}set ready(t){this.setAttribute("ready",t)}get timeout(){let t=this.hasAttribute("timeout")?this.getAttribute("timeout"):1500;return parseInt(t,10)}set timeout(t){Number.isNaN(t)||this.setAttribute("timeout",t)}attributeChangedCallback(t,e,n){switch(t){case"ready":{if(n!=="null"){let r=new Event("ready");this.innerText="",this.dispatchEvent(r)}break}case"flash":{let r=setTimeout(()=>{clearTimeout(r),this.ready=!0},this.timeout);this.innerText=n,this.ready=null;break}}}},I=(s,t,e,n,r,o)=>{let c=s.canvas||s,b=t.canvas||t,y=e||0,E=n||0,v=r||0,x=o||0,[u,d]=[c.width-y,c.height-E],w=b.context||b.getContext("2d");w.clearRect(v,x,u,d),w.drawImage(c,y,E,u,d,v,x,u,d)},m=s=>({get context(){return this.canvas.getContext("2d")},canvas:s,source(t,e,n){return I(t,this.context,e,n),this},target(t,e,n){return I(this.context,t,0,0,e,n),this}}),j=(s,t=s)=>{let e=document.createElement("canvas"),n=Object.assign(e,{width:s,height:t});return m(n)};"customElements"in window&&(customElements.define("just-scream",A),customElements.define("just-flash",q));var i=document.getElementById("canvas"),f=document.createElement("img"),R=m(i),l=m(i.cloneNode());i.after(l.canvas);R.context.rotate(Math.PI/180);l.context.rotate(Math.PI/-90);var{width:g,height:L}=i,M=j(g,L),N=s=>{let t=s.getImageData(0,0,g,L),e=t.data;for(let n=0,r=e.length;n<r;n+=4){let o=e[n+2],c=e[n+3];e[n+2]=o>25?o:255,e[n+3]=e[n+2]===255?0:c}s.putImageData(t,0,0)},p=0,{start:z}=T((s,t)=>{if(t%15==0){let e=g*p;M.source(f,e,0).target(R).target(l),N(l.context),p+=1,p%=119}}),S=document.querySelector("just-flash");S.addEventListener("ready",z);f.setAttribute("src","film.png");f.addEventListener("load",()=>{S.ready=!0});self.addEventListener("load",()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("serviceworker.js").catch(console.log)});})();

M client.js => client.js +4 -5
@@ 7,14 7,13 @@ if ("customElements" in window) {
  customElements.define("just-flash", Flash)
}

const figure = document.getElementById("figure")
const canvas = document.getElementById("canvas")
const master = document.createElement("img")

const background = pictureFrom(canvas)
const foreground = pictureFrom(canvas.cloneNode())

figure.appendChild(foreground.canvas)
canvas.after(foreground.canvas)

background.context.rotate(Math.PI / 180)
foreground.context.rotate(Math.PI / -90)


@@ 53,14 52,14 @@ const { start } = createLoop((_, frame) => {

const flash = document.querySelector("just-flash")

flash.addEventListener("ready", start)

master.setAttribute("src", "film.png")
master.addEventListener("load", () => {
  flash.ready = true
})

flash.addEventListener("ready", start)

window.addEventListener("load", () => {
self.addEventListener("load", () => {
  if ("serviceWorker" in navigator) {
    navigator.serviceWorker.register("serviceworker.js").catch(console.log)
  }