@johnfmorton/some-shade 1.0.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0 - 2026-03-01
4
+
5
+ - Add `reference-width` attribute (default 1024) — normalizes `u_gridSize` and `u_dotRadius` by source image width so the dot pattern looks visually consistent regardless of image resolution
6
+
3
7
  ## 0.1.1-beta
4
8
 
5
9
  - Fix halftone-duotone and halftone-cmyk shaders to sample at grid cell center — dots are now clean, uniform circles instead of splotchy per-pixel noise
package/dist/index.d.ts CHANGED
@@ -43,14 +43,12 @@ export declare class SomeShadeImage extends LitElement {
43
43
  warmColor: string;
44
44
  coolColor: string;
45
45
  blendMode: number;
46
- loadingBlur: number;
46
+ referenceWidth: number;
47
47
  private _webglAvailable;
48
48
  private _snapshotUrl;
49
49
  private _snapshotLoaded;
50
50
  private _image;
51
51
  private _observer;
52
- private _resizeObserver;
53
- private _lastClientWidth;
54
52
  private _visible;
55
53
  private _needsRender;
56
54
  render(): TemplateResult<1>;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("lit"),l=require("lit/decorators.js");function k(t){return t.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!0})}function E(t,o,r){const i=t.createShader(o);if(!i)throw new Error("Failed to create shader");if(t.shaderSource(i,r),t.compileShader(i),!t.getShaderParameter(i,t.COMPILE_STATUS)){const e=t.getShaderInfoLog(i);throw t.deleteShader(i),new Error(`Shader compile error: ${e}`)}return i}function D(t,o,r){const i=E(t,t.VERTEX_SHADER,o),e=E(t,t.FRAGMENT_SHADER,r),n=t.createProgram();if(!n)throw new Error("Failed to create program");if(t.attachShader(n,i),t.attachShader(n,e),t.linkProgram(n),!t.getProgramParameter(n,t.LINK_STATUS)){const d=t.getProgramInfoLog(n);throw t.deleteProgram(n),new Error(`Program link error: ${d}`)}t.deleteShader(i),t.deleteShader(e);const c=new Map,h=t.getProgramParameter(n,t.ACTIVE_ATTRIBUTES);for(let d=0;d<h;d++){const f=t.getActiveAttrib(n,d);f&&c.set(f.name,t.getAttribLocation(n,f.name))}const s=new Map,g=t.getProgramParameter(n,t.ACTIVE_UNIFORMS);for(let d=0;d<g;d++){const f=t.getActiveUniform(n,d);if(f){const m=t.getUniformLocation(n,f.name);m&&s.set(f.name,m)}}return{program:n,attribLocations:c,uniformLocations:s}}function L(t,o,r){for(const[i,e]of Object.entries(r)){const n=o.uniformLocations.get(i);if(n){if(typeof e=="number")t.uniform1f(n,e);else if(Array.isArray(e))switch(e.length){case 2:t.uniform2fv(n,e);break;case 3:t.uniform3fv(n,e);break;case 4:t.uniform4fv(n,e);break}}}}function z(t,o){const r=t.createTexture();if(!r)throw new Error("Failed to create texture");return t.bindTexture(t.TEXTURE_2D,r),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,o),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),{texture:r,width:o.naturalWidth,height:o.naturalHeight}}function M(t,o){const r=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,1,1,1,0]),i=t.createBuffer();if(!i)throw new Error("Failed to create buffer");t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,r,t.STATIC_DRAW);const e=4*Float32Array.BYTES_PER_ELEMENT,n=o.attribLocations.get("a_position");n!==void 0&&n!==-1&&(t.enableVertexAttribArray(n),t.vertexAttribPointer(n,2,t.FLOAT,!1,e,0));const c=o.attribLocations.get("a_texCoord");return c!==void 0&&c!==-1&&(t.enableVertexAttribArray(c),t.vertexAttribPointer(c,2,t.FLOAT,!1,e,2*Float32Array.BYTES_PER_ELEMENT)),i}function P(t){t.drawArrays(t.TRIANGLE_STRIP,0,4)}const O=`precision mediump float;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("lit"),l=require("lit/decorators.js");function U(e){return e.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!0})}function E(e,o,a){const t=e.createShader(o);if(!t)throw new Error("Failed to create shader");if(e.shaderSource(t,a),e.compileShader(t),!e.getShaderParameter(t,e.COMPILE_STATUS)){const s=e.getShaderInfoLog(t);throw e.deleteShader(t),new Error(`Shader compile error: ${s}`)}return t}function K(e,o,a){const t=E(e,e.VERTEX_SHADER,o),s=E(e,e.FRAGMENT_SHADER,a),n=e.createProgram();if(!n)throw new Error("Failed to create program");if(e.attachShader(n,t),e.attachShader(n,s),e.linkProgram(n),!e.getProgramParameter(n,e.LINK_STATUS)){const d=e.getProgramInfoLog(n);throw e.deleteProgram(n),new Error(`Program link error: ${d}`)}e.deleteShader(t),e.deleteShader(s);const r=new Map,g=e.getProgramParameter(n,e.ACTIVE_ATTRIBUTES);for(let d=0;d<g;d++){const f=e.getActiveAttrib(n,d);f&&r.set(f.name,e.getAttribLocation(n,f.name))}const c=new Map,h=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let d=0;d<h;d++){const f=e.getActiveUniform(n,d);if(f){const m=e.getUniformLocation(n,f.name);m&&c.set(f.name,m)}}return{program:n,attribLocations:r,uniformLocations:c}}function k(e,o,a){for(const[t,s]of Object.entries(a)){const n=o.uniformLocations.get(t);if(n){if(typeof s=="number")e.uniform1f(n,s);else if(Array.isArray(s))switch(s.length){case 2:e.uniform2fv(n,s);break;case 3:e.uniform3fv(n,s);break;case 4:e.uniform4fv(n,s);break}}}}function D(e,o){const a=e.createTexture();if(!a)throw new Error("Failed to create texture");return e.bindTexture(e.TEXTURE_2D,a),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,o),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),{texture:a,width:o.naturalWidth,height:o.naturalHeight}}function L(e,o){const a=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,1,1,1,0]),t=e.createBuffer();if(!t)throw new Error("Failed to create buffer");e.bindBuffer(e.ARRAY_BUFFER,t),e.bufferData(e.ARRAY_BUFFER,a,e.STATIC_DRAW);const s=4*Float32Array.BYTES_PER_ELEMENT,n=o.attribLocations.get("a_position");n!==void 0&&n!==-1&&(e.enableVertexAttribArray(n),e.vertexAttribPointer(n,2,e.FLOAT,!1,s,0));const r=o.attribLocations.get("a_texCoord");return r!==void 0&&r!==-1&&(e.enableVertexAttribArray(r),e.vertexAttribPointer(r,2,e.FLOAT,!1,s,2*Float32Array.BYTES_PER_ELEMENT)),t}function M(e){e.drawArrays(e.TRIANGLE_STRIP,0,4)}const z=`precision mediump float;
2
2
 
3
3
  varying vec2 v_texCoord;
4
4
 
@@ -92,7 +92,7 @@ void main() {
92
92
  gl_Position = vec4(a_position, 0.0, 1.0);
93
93
  v_texCoord = a_texCoord;
94
94
  }
95
- `,I={name:"halftone-cmyk",fragmentShader:O,vertexShader:y,uniforms:[{name:"u_dotRadius",type:"float",default:4,attribute:"dot-radius"},{name:"u_gridSize",type:"float",default:8,attribute:"grid-size"},{name:"u_angleC",type:"float",default:15,attribute:"angle-c"},{name:"u_angleM",type:"float",default:75,attribute:"angle-m"},{name:"u_angleY",type:"float",default:0,attribute:"angle-y"},{name:"u_angleK",type:"float",default:45,attribute:"angle-k"},{name:"u_showC",type:"float",default:1,attribute:"show-c"},{name:"u_showM",type:"float",default:1,attribute:"show-m"},{name:"u_showY",type:"float",default:1,attribute:"show-y"},{name:"u_showK",type:"float",default:1,attribute:"show-k"},{name:"u_intensityK",type:"float",default:1,attribute:"intensity-k"}]},V=`precision mediump float;
95
+ `,P={name:"halftone-cmyk",fragmentShader:z,vertexShader:y,uniforms:[{name:"u_dotRadius",type:"float",default:4,attribute:"dot-radius"},{name:"u_gridSize",type:"float",default:8,attribute:"grid-size"},{name:"u_angleC",type:"float",default:15,attribute:"angle-c"},{name:"u_angleM",type:"float",default:75,attribute:"angle-m"},{name:"u_angleY",type:"float",default:0,attribute:"angle-y"},{name:"u_angleK",type:"float",default:45,attribute:"angle-k"},{name:"u_showC",type:"float",default:1,attribute:"show-c"},{name:"u_showM",type:"float",default:1,attribute:"show-m"},{name:"u_showY",type:"float",default:1,attribute:"show-y"},{name:"u_showK",type:"float",default:1,attribute:"show-k"},{name:"u_intensityK",type:"float",default:1,attribute:"intensity-k"}]},V=`precision mediump float;
96
96
 
97
97
  varying vec2 v_texCoord;
98
98
 
@@ -134,7 +134,7 @@ void main() {
134
134
 
135
135
  gl_FragColor = vec4(result, color.a);
136
136
  }
137
- `,W={name:"halftone-duotone",fragmentShader:V,vertexShader:y,uniforms:[{name:"u_dotRadius",type:"float",default:4,attribute:"dot-radius"},{name:"u_gridSize",type:"float",default:8,attribute:"grid-size"},{name:"u_duotoneColor",type:"vec3",default:[0,.6,.8],attribute:"duotone-color"},{name:"u_angle",type:"float",default:0,attribute:"angle"}]},N=`precision mediump float;
137
+ `,I={name:"halftone-duotone",fragmentShader:V,vertexShader:y,uniforms:[{name:"u_dotRadius",type:"float",default:4,attribute:"dot-radius"},{name:"u_gridSize",type:"float",default:8,attribute:"grid-size"},{name:"u_duotoneColor",type:"vec3",default:[0,.6,.8],attribute:"duotone-color"},{name:"u_angle",type:"float",default:0,attribute:"angle"}]},O=`precision mediump float;
138
138
 
139
139
  varying vec2 v_texCoord;
140
140
 
@@ -190,7 +190,7 @@ void main() {
190
190
 
191
191
  gl_FragColor = vec4(result, 1.0);
192
192
  }
193
- `,F={name:"dot-grid",fragmentShader:N,vertexShader:y,uniforms:[{name:"u_dotRadius",type:"float",default:4,attribute:"dot-radius"},{name:"u_gridSize",type:"float",default:8,attribute:"grid-size"},{name:"u_dotOffset",type:"vec2",default:[.5,.5],attribute:"dot-offset"},{name:"u_bgColor",type:"vec3",default:[1,1,1],attribute:"bg-color"},{name:"u_angle",type:"float",default:0,attribute:"angle"}]},B=`precision mediump float;
193
+ `,N={name:"dot-grid",fragmentShader:O,vertexShader:y,uniforms:[{name:"u_dotRadius",type:"float",default:4,attribute:"dot-radius"},{name:"u_gridSize",type:"float",default:8,attribute:"grid-size"},{name:"u_dotOffset",type:"vec2",default:[.5,.5],attribute:"dot-offset"},{name:"u_bgColor",type:"vec3",default:[1,1,1],attribute:"bg-color"},{name:"u_angle",type:"float",default:0,attribute:"angle"}]},F=`precision mediump float;
194
194
 
195
195
  varying vec2 v_texCoord;
196
196
 
@@ -273,14 +273,14 @@ void main() {
273
273
 
274
274
  gl_FragColor = vec4(clamp(result, 0.0, 1.0), color.a);
275
275
  }
276
- `,Y={name:"technicolor-2strip",fragmentShader:B,vertexShader:y,uniforms:[{name:"u_dotRadius",type:"float",default:7,attribute:"dot-radius"},{name:"u_gridSize",type:"float",default:10,attribute:"grid-size"},{name:"u_angleWarm",type:"float",default:15,attribute:"angle-warm"},{name:"u_angleCool",type:"float",default:75,attribute:"angle-cool"},{name:"u_angleK",type:"float",default:45,attribute:"angle-k"},{name:"u_showWarm",type:"float",default:1,attribute:"show-warm"},{name:"u_showCool",type:"float",default:1,attribute:"show-cool"},{name:"u_showK",type:"float",default:1,attribute:"show-k"},{name:"u_warmColor",type:"vec3",default:[.85,.25,.06],attribute:"warm-color"},{name:"u_coolColor",type:"vec3",default:[.05,.65,.6],attribute:"cool-color"},{name:"u_blendMode",type:"float",default:1,attribute:"blend-mode"},{name:"u_intensityK",type:"float",default:1,attribute:"intensity-k"}]},w=new Map;function p(t){w.set(t.name,t)}function U(t){return w.get(t)}function X(){return Array.from(w.keys())}p(I);p(W);p(F);p(Y);var $=Object.defineProperty,u=(t,o,r,i)=>{for(var e=void 0,n=t.length-1,c;n>=0;n--)(c=t[n])&&(e=c(o,r,e)||e);return e&&$(o,r,e),e};const G=2;let T=Promise.resolve();function A(t){const o=T.then(t,t);return T=o,o}const H=new Set(["effect","dotRadius","gridSize","angleC","angleM","angleY","angleK","showC","showM","showY","showK","intensityK","duotoneColor","angle","dotOffsetX","dotOffsetY","bgColor","angleWarm","angleCool","showWarm","showCool","warmColor","coolColor","blendMode"]),C=class C extends _.LitElement{constructor(){super(...arguments),this.src="",this.effect="halftone-cmyk",this.dotRadius=4,this.gridSize=8,this.angleC=15,this.angleM=75,this.angleY=0,this.angleK=45,this.showC=1,this.showM=1,this.showY=1,this.showK=1,this.intensityK=1,this.duotoneColor="#0099cc",this.angle=0,this.dotOffsetX=.5,this.dotOffsetY=.5,this.bgColor="#ffffff",this.angleWarm=15,this.angleCool=75,this.showWarm=1,this.showCool=1,this.warmColor="#d94010",this.coolColor="#0da699",this.blendMode=1,this.loadingBlur=0,this._webglAvailable=!0,this._snapshotUrl="",this._snapshotLoaded=!1,this._image=null,this._observer=null,this._resizeObserver=null,this._lastClientWidth=0,this._visible=!1,this._needsRender=!1}render(){if(!this._webglAvailable)return _.html`<img src=${this.src} alt="" />`;const o=this.loadingBlur>0?`filter: blur(${this.loadingBlur}px)`:"";return _.html`
277
- <img src=${this.src} alt="" style=${o} />
278
- ${this._snapshotUrl?_.html`<img
276
+ `,W={name:"technicolor-2strip",fragmentShader:F,vertexShader:y,uniforms:[{name:"u_dotRadius",type:"float",default:7,attribute:"dot-radius"},{name:"u_gridSize",type:"float",default:10,attribute:"grid-size"},{name:"u_angleWarm",type:"float",default:15,attribute:"angle-warm"},{name:"u_angleCool",type:"float",default:75,attribute:"angle-cool"},{name:"u_angleK",type:"float",default:45,attribute:"angle-k"},{name:"u_showWarm",type:"float",default:1,attribute:"show-warm"},{name:"u_showCool",type:"float",default:1,attribute:"show-cool"},{name:"u_showK",type:"float",default:1,attribute:"show-k"},{name:"u_warmColor",type:"vec3",default:[.85,.25,.06],attribute:"warm-color"},{name:"u_coolColor",type:"vec3",default:[.05,.65,.6],attribute:"cool-color"},{name:"u_blendMode",type:"float",default:1,attribute:"blend-mode"},{name:"u_intensityK",type:"float",default:1,attribute:"intensity-k"}]},C=new Map;function _(e){C.set(e.name,e)}function T(e){return C.get(e)}function Y(){return Array.from(C.keys())}_(P);_(I);_(N);_(W);var B=Object.defineProperty,u=(e,o,a,t)=>{for(var s=void 0,n=e.length-1,r;n>=0;n--)(r=e[n])&&(s=r(o,a,s)||s);return s&&B(o,a,s),s};const X=2;let x=Promise.resolve();function w(e){const o=x.then(e,e);return x=o,o}const G=new Set(["effect","dotRadius","gridSize","angleC","angleM","angleY","angleK","showC","showM","showY","showK","intensityK","duotoneColor","angle","dotOffsetX","dotOffsetY","bgColor","angleWarm","angleCool","showWarm","showCool","warmColor","coolColor","blendMode","referenceWidth"]),R=class R extends p.LitElement{constructor(){super(...arguments),this.src="",this.effect="halftone-cmyk",this.dotRadius=4,this.gridSize=8,this.angleC=15,this.angleM=75,this.angleY=0,this.angleK=45,this.showC=1,this.showM=1,this.showY=1,this.showK=1,this.intensityK=1,this.duotoneColor="#0099cc",this.angle=0,this.dotOffsetX=.5,this.dotOffsetY=.5,this.bgColor="#ffffff",this.angleWarm=15,this.angleCool=75,this.showWarm=1,this.showCool=1,this.warmColor="#d94010",this.coolColor="#0da699",this.blendMode=1,this.referenceWidth=1024,this._webglAvailable=!0,this._snapshotUrl="",this._snapshotLoaded=!1,this._image=null,this._observer=null,this._visible=!1,this._needsRender=!1}render(){return this._webglAvailable?p.html`
277
+ <img class="base" src=${this.src} alt="" />
278
+ ${this._snapshotUrl?p.html`<img
279
279
  class="snapshot${this._snapshotLoaded?" loaded":""}"
280
280
  src=${this._snapshotUrl}
281
281
  @load=${this._onSnapshotLoad}
282
282
  alt="" />`:""}
283
- `}connectedCallback(){super.connectedCallback(),this._observer=new IntersectionObserver(o=>{var i;const r=this._visible;this._visible=((i=o[0])==null?void 0:i.isIntersecting)??!1,this._visible&&!r&&this._needsRender&&(this._needsRender=!1,A(()=>this._renderEffect()))},{rootMargin:"200px"}),this._observer.observe(this),this._resizeObserver=new ResizeObserver(()=>{if(!this._image)return;const o=this.clientWidth;o>0&&o!==this._lastClientWidth&&(this._lastClientWidth=o,this._scheduleRender())}),this._resizeObserver.observe(this)}updated(o){if(o.has("src")&&this.src){this._loadImage(this.src);return}if(!this._image)return;[...o.keys()].some(i=>H.has(i))&&this._scheduleRender()}disconnectedCallback(){var o,r;super.disconnectedCallback(),(o=this._observer)==null||o.disconnect(),(r=this._resizeObserver)==null||r.disconnect(),this._revokeSnapshot()}_loadImage(o){const r=new Image;r.crossOrigin="anonymous",r.onload=()=>{this._image=r,this._scheduleRender()},r.onerror=()=>{console.warn(`[some-shade] Failed to load image: ${o}`)},r.src=o}_scheduleRender(){this._visible?A(()=>this._renderEffect()):this._needsRender=!0}async _renderEffect(){var g;if(!this._image)return;const o=U(this.effect);if(!o){console.warn(`[some-shade] Unknown effect: ${this.effect}`);return}const r=Math.min(window.devicePixelRatio||1,G),i=this._image.naturalWidth,e=this._image.naturalHeight,n=this.clientWidth||i,c=Math.max(1,i/n);this._lastClientWidth=this.clientWidth;const h=document.createElement("canvas");h.width=i*r,h.height=e*r;const s=k(h);if(!s){this._webglAvailable=!1;return}try{const d=D(s,o.vertexShader,o.fragmentShader);s.useProgram(d.program);const f=z(s,this._image),m=M(s,d);s.viewport(0,0,h.width,h.height),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,f.texture);const R=d.uniformLocations.get("u_image");R&&s.uniform1i(R,0),L(s,d,this._getUniformValues(f,r,c)),s.bindBuffer(s.ARRAY_BUFFER,m);const S=4*Float32Array.BYTES_PER_ELEMENT,b=d.attribLocations.get("a_position");b!==void 0&&b!==-1&&(s.enableVertexAttribArray(b),s.vertexAttribPointer(b,2,s.FLOAT,!1,S,0));const v=d.attribLocations.get("a_texCoord");v!==void 0&&v!==-1&&(s.enableVertexAttribArray(v),s.vertexAttribPointer(v,2,s.FLOAT,!1,S,2*Float32Array.BYTES_PER_ELEMENT)),P(s);const x=await new Promise(K=>h.toBlob(K));s.deleteTexture(f.texture),s.deleteProgram(d.program),s.deleteBuffer(m),x&&(this._snapshotLoaded=!1,this._revokeSnapshot(),this._snapshotUrl=URL.createObjectURL(x))}finally{(g=s.getExtension("WEBGL_lose_context"))==null||g.loseContext()}}_onSnapshotLoad(){this._snapshotLoaded=!0}replayTransition(o=500){this._snapshotUrl&&(this._snapshotLoaded=!1,this.updateComplete.then(()=>{setTimeout(()=>{this._snapshotLoaded=!0},o)}))}_revokeSnapshot(){this._snapshotUrl&&(URL.revokeObjectURL(this._snapshotUrl),this._snapshotUrl="")}_getUniformValues(o,r,i){const e={};return e.u_resolution=[o.width*r,o.height*r],e.u_dotRadius=this.dotRadius*i,e.u_gridSize=this.gridSize*i,this.effect==="halftone-cmyk"?(e.u_angleC=this.angleC,e.u_angleM=this.angleM,e.u_angleY=this.angleY,e.u_angleK=this.angleK,e.u_showC=this.showC,e.u_showM=this.showM,e.u_showY=this.showY,e.u_showK=this.showK,e.u_intensityK=this.intensityK):this.effect==="halftone-duotone"?(e.u_duotoneColor=this._parseHexColor(this.duotoneColor),e.u_angle=this.angle):this.effect==="dot-grid"?(e.u_dotOffset=[this.dotOffsetX,this.dotOffsetY],e.u_bgColor=this._parseHexColor(this.bgColor),e.u_angle=this.angle):this.effect==="technicolor-2strip"&&(e.u_angleWarm=this.angleWarm,e.u_angleCool=this.angleCool,e.u_angleK=this.angleK,e.u_showWarm=this.showWarm,e.u_showCool=this.showCool,e.u_showK=this.showK,e.u_warmColor=this._parseHexColor(this.warmColor),e.u_coolColor=this._parseHexColor(this.coolColor),e.u_blendMode=this.blendMode,e.u_intensityK=this.intensityK),e}_parseHexColor(o){const r=o.replace("#",""),i=parseInt(r.substring(0,2),16)/255,e=parseInt(r.substring(2,4),16)/255,n=parseInt(r.substring(4,6),16)/255;return[i,e,n]}};C.styles=_.css`
283
+ `:p.html`<img src=${this.src} alt="" />`}connectedCallback(){super.connectedCallback(),this._observer=new IntersectionObserver(o=>{var t;const a=this._visible;this._visible=((t=o[0])==null?void 0:t.isIntersecting)??!1,this._visible&&!a&&(this._needsRender||this._image&&!this._snapshotUrl)&&(this._needsRender=!1,w(()=>this._renderEffect()))},{rootMargin:"200px"}),this._observer.observe(this)}updated(o){if(o.has("src")&&this.src){this._loadImage(this.src);return}if(!this._image)return;[...o.keys()].some(t=>G.has(t))&&this._scheduleRender()}disconnectedCallback(){var o;super.disconnectedCallback(),(o=this._observer)==null||o.disconnect(),this._revokeSnapshot()}_loadImage(o){const a=new Image;a.crossOrigin="anonymous",a.onload=()=>{this._image=a,this._scheduleRender()},a.onerror=()=>{console.warn(`[some-shade] Failed to load image: ${o}`)},a.src=o}_scheduleRender(){this._visible?w(()=>this._renderEffect()):(this._needsRender=!0,requestAnimationFrame(()=>{if(this._needsRender&&!this._visible){const o=this.getBoundingClientRect();o.bottom>=0&&o.top<window.innerHeight&&(this._visible=!0,this._needsRender=!1,w(()=>this._renderEffect()))}}))}async _renderEffect(){var g;if(!this._image)return;const o=T(this.effect);if(!o){console.warn(`[some-shade] Unknown effect: ${this.effect}`);return}const a=Math.min(window.devicePixelRatio||1,X),t=this._image.naturalWidth,s=this._image.naturalHeight,n=document.createElement("canvas");n.width=t*a,n.height=s*a;const r=U(n);if(!r){this._webglAvailable=!1;return}try{const c=K(r,o.vertexShader,o.fragmentShader);r.useProgram(c.program);const h=D(r,this._image),d=L(r,c);r.viewport(0,0,n.width,n.height),r.clearColor(0,0,0,0),r.clear(r.COLOR_BUFFER_BIT),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,h.texture);const f=c.uniformLocations.get("u_image");f&&r.uniform1i(f,0),k(r,c,this._getUniformValues(h,a)),r.bindBuffer(r.ARRAY_BUFFER,d);const m=4*Float32Array.BYTES_PER_ELEMENT,b=c.attribLocations.get("a_position");b!==void 0&&b!==-1&&(r.enableVertexAttribArray(b),r.vertexAttribPointer(b,2,r.FLOAT,!1,m,0));const v=c.attribLocations.get("a_texCoord");v!==void 0&&v!==-1&&(r.enableVertexAttribArray(v),r.vertexAttribPointer(v,2,r.FLOAT,!1,m,2*Float32Array.BYTES_PER_ELEMENT)),M(r);const S=await new Promise(A=>n.toBlob(A));r.deleteTexture(h.texture),r.deleteProgram(c.program),r.deleteBuffer(d),S&&(this._snapshotLoaded=!1,this._revokeSnapshot(),this._snapshotUrl=URL.createObjectURL(S))}finally{(g=r.getExtension("WEBGL_lose_context"))==null||g.loseContext()}}_onSnapshotLoad(){this._snapshotLoaded=!0}replayTransition(o=500){this._snapshotUrl&&(this._snapshotLoaded=!1,this.updateComplete.then(()=>{setTimeout(()=>{this._snapshotLoaded=!0},o)}))}_revokeSnapshot(){this._snapshotUrl&&(URL.revokeObjectURL(this._snapshotUrl),this._snapshotUrl="")}_getUniformValues(o,a){const t={};t.u_resolution=[o.width*a,o.height*a];const s=o.width/this.referenceWidth;return t.u_dotRadius=this.dotRadius*s,t.u_gridSize=this.gridSize*s,this.effect==="halftone-cmyk"?(t.u_angleC=this.angleC,t.u_angleM=this.angleM,t.u_angleY=this.angleY,t.u_angleK=this.angleK,t.u_showC=this.showC,t.u_showM=this.showM,t.u_showY=this.showY,t.u_showK=this.showK,t.u_intensityK=this.intensityK):this.effect==="halftone-duotone"?(t.u_duotoneColor=this._parseHexColor(this.duotoneColor),t.u_angle=this.angle):this.effect==="dot-grid"?(t.u_dotOffset=[this.dotOffsetX,this.dotOffsetY],t.u_bgColor=this._parseHexColor(this.bgColor),t.u_angle=this.angle):this.effect==="technicolor-2strip"&&(t.u_angleWarm=this.angleWarm,t.u_angleCool=this.angleCool,t.u_angleK=this.angleK,t.u_showWarm=this.showWarm,t.u_showCool=this.showCool,t.u_showK=this.showK,t.u_warmColor=this._parseHexColor(this.warmColor),t.u_coolColor=this._parseHexColor(this.coolColor),t.u_blendMode=this.blendMode,t.u_intensityK=this.intensityK),t}_parseHexColor(o){const a=o.replace("#",""),t=parseInt(a.substring(0,2),16)/255,s=parseInt(a.substring(2,4),16)/255,n=parseInt(a.substring(4,6),16)/255;return[t,s,n]}};R.styles=p.css`
284
284
  :host {
285
285
  display: block;
286
286
  position: relative;
@@ -292,6 +292,9 @@ void main() {
292
292
  width: 100%;
293
293
  height: auto;
294
294
  }
295
+ img.base {
296
+ opacity: 0;
297
+ }
295
298
  img.snapshot {
296
299
  position: absolute;
297
300
  inset: 0;
@@ -303,4 +306,4 @@ void main() {
303
306
  img.snapshot.loaded {
304
307
  opacity: 1;
305
308
  }
306
- `;let a=C;u([l.property()],a.prototype,"src");u([l.property()],a.prototype,"effect");u([l.property({type:Number,attribute:"dot-radius"})],a.prototype,"dotRadius");u([l.property({type:Number,attribute:"grid-size"})],a.prototype,"gridSize");u([l.property({type:Number,attribute:"angle-c"})],a.prototype,"angleC");u([l.property({type:Number,attribute:"angle-m"})],a.prototype,"angleM");u([l.property({type:Number,attribute:"angle-y"})],a.prototype,"angleY");u([l.property({type:Number,attribute:"angle-k"})],a.prototype,"angleK");u([l.property({type:Number,attribute:"show-c"})],a.prototype,"showC");u([l.property({type:Number,attribute:"show-m"})],a.prototype,"showM");u([l.property({type:Number,attribute:"show-y"})],a.prototype,"showY");u([l.property({type:Number,attribute:"show-k"})],a.prototype,"showK");u([l.property({type:Number,attribute:"intensity-k"})],a.prototype,"intensityK");u([l.property({attribute:"duotone-color"})],a.prototype,"duotoneColor");u([l.property({type:Number})],a.prototype,"angle");u([l.property({type:Number,attribute:"dot-offset-x"})],a.prototype,"dotOffsetX");u([l.property({type:Number,attribute:"dot-offset-y"})],a.prototype,"dotOffsetY");u([l.property({attribute:"bg-color"})],a.prototype,"bgColor");u([l.property({type:Number,attribute:"angle-warm"})],a.prototype,"angleWarm");u([l.property({type:Number,attribute:"angle-cool"})],a.prototype,"angleCool");u([l.property({type:Number,attribute:"show-warm"})],a.prototype,"showWarm");u([l.property({type:Number,attribute:"show-cool"})],a.prototype,"showCool");u([l.property({attribute:"warm-color"})],a.prototype,"warmColor");u([l.property({attribute:"cool-color"})],a.prototype,"coolColor");u([l.property({type:Number,attribute:"blend-mode"})],a.prototype,"blendMode");u([l.property({type:Number,attribute:"loading-blur"})],a.prototype,"loadingBlur");u([l.state()],a.prototype,"_webglAvailable");u([l.state()],a.prototype,"_snapshotUrl");u([l.state()],a.prototype,"_snapshotLoaded");customElements.get("some-shade-image")||customElements.define("some-shade-image",a);exports.SomeShadeImage=a;exports.get=U;exports.list=X;exports.register=p;
309
+ `;let i=R;u([l.property()],i.prototype,"src");u([l.property()],i.prototype,"effect");u([l.property({type:Number,attribute:"dot-radius"})],i.prototype,"dotRadius");u([l.property({type:Number,attribute:"grid-size"})],i.prototype,"gridSize");u([l.property({type:Number,attribute:"angle-c"})],i.prototype,"angleC");u([l.property({type:Number,attribute:"angle-m"})],i.prototype,"angleM");u([l.property({type:Number,attribute:"angle-y"})],i.prototype,"angleY");u([l.property({type:Number,attribute:"angle-k"})],i.prototype,"angleK");u([l.property({type:Number,attribute:"show-c"})],i.prototype,"showC");u([l.property({type:Number,attribute:"show-m"})],i.prototype,"showM");u([l.property({type:Number,attribute:"show-y"})],i.prototype,"showY");u([l.property({type:Number,attribute:"show-k"})],i.prototype,"showK");u([l.property({type:Number,attribute:"intensity-k"})],i.prototype,"intensityK");u([l.property({attribute:"duotone-color"})],i.prototype,"duotoneColor");u([l.property({type:Number})],i.prototype,"angle");u([l.property({type:Number,attribute:"dot-offset-x"})],i.prototype,"dotOffsetX");u([l.property({type:Number,attribute:"dot-offset-y"})],i.prototype,"dotOffsetY");u([l.property({attribute:"bg-color"})],i.prototype,"bgColor");u([l.property({type:Number,attribute:"angle-warm"})],i.prototype,"angleWarm");u([l.property({type:Number,attribute:"angle-cool"})],i.prototype,"angleCool");u([l.property({type:Number,attribute:"show-warm"})],i.prototype,"showWarm");u([l.property({type:Number,attribute:"show-cool"})],i.prototype,"showCool");u([l.property({attribute:"warm-color"})],i.prototype,"warmColor");u([l.property({attribute:"cool-color"})],i.prototype,"coolColor");u([l.property({type:Number,attribute:"blend-mode"})],i.prototype,"blendMode");u([l.property({type:Number,attribute:"reference-width"})],i.prototype,"referenceWidth");u([l.state()],i.prototype,"_webglAvailable");u([l.state()],i.prototype,"_snapshotUrl");u([l.state()],i.prototype,"_snapshotLoaded");customElements.get("some-shade-image")||customElements.define("some-shade-image",i);exports.SomeShadeImage=i;exports.get=T;exports.list=Y;exports.register=_;
@@ -1,72 +1,72 @@
1
- import { LitElement as k, css as D, html as y } from "lit";
2
- import { property as u, state as w } from "lit/decorators.js";
3
- function L(t) {
4
- return t.getContext("webgl", {
1
+ import { LitElement as U, css as K, html as y } from "lit";
2
+ import { property as u, state as C } from "lit/decorators.js";
3
+ function k(e) {
4
+ return e.getContext("webgl", {
5
5
  alpha: !0,
6
6
  premultipliedAlpha: !1,
7
7
  preserveDrawingBuffer: !0
8
8
  });
9
9
  }
10
- function T(t, o, n) {
11
- const i = t.createShader(o);
12
- if (!i) throw new Error("Failed to create shader");
13
- if (t.shaderSource(i, n), t.compileShader(i), !t.getShaderParameter(i, t.COMPILE_STATUS)) {
14
- const e = t.getShaderInfoLog(i);
15
- throw t.deleteShader(i), new Error(`Shader compile error: ${e}`);
10
+ function x(e, o, a) {
11
+ const t = e.createShader(o);
12
+ if (!t) throw new Error("Failed to create shader");
13
+ if (e.shaderSource(t, a), e.compileShader(t), !e.getShaderParameter(t, e.COMPILE_STATUS)) {
14
+ const s = e.getShaderInfoLog(t);
15
+ throw e.deleteShader(t), new Error(`Shader compile error: ${s}`);
16
16
  }
17
- return i;
17
+ return t;
18
18
  }
19
- function z(t, o, n) {
20
- const i = T(t, t.VERTEX_SHADER, o), e = T(t, t.FRAGMENT_SHADER, n), r = t.createProgram();
19
+ function D(e, o, a) {
20
+ const t = x(e, e.VERTEX_SHADER, o), s = x(e, e.FRAGMENT_SHADER, a), r = e.createProgram();
21
21
  if (!r) throw new Error("Failed to create program");
22
- if (t.attachShader(r, i), t.attachShader(r, e), t.linkProgram(r), !t.getProgramParameter(r, t.LINK_STATUS)) {
23
- const d = t.getProgramInfoLog(r);
24
- throw t.deleteProgram(r), new Error(`Program link error: ${d}`);
22
+ if (e.attachShader(r, t), e.attachShader(r, s), e.linkProgram(r), !e.getProgramParameter(r, e.LINK_STATUS)) {
23
+ const d = e.getProgramInfoLog(r);
24
+ throw e.deleteProgram(r), new Error(`Program link error: ${d}`);
25
25
  }
26
- t.deleteShader(i), t.deleteShader(e);
27
- const c = /* @__PURE__ */ new Map(), h = t.getProgramParameter(r, t.ACTIVE_ATTRIBUTES);
28
- for (let d = 0; d < h; d++) {
29
- const f = t.getActiveAttrib(r, d);
30
- f && c.set(f.name, t.getAttribLocation(r, f.name));
31
- }
32
- const s = /* @__PURE__ */ new Map(), _ = t.getProgramParameter(r, t.ACTIVE_UNIFORMS);
26
+ e.deleteShader(t), e.deleteShader(s);
27
+ const n = /* @__PURE__ */ new Map(), _ = e.getProgramParameter(r, e.ACTIVE_ATTRIBUTES);
33
28
  for (let d = 0; d < _; d++) {
34
- const f = t.getActiveUniform(r, d);
35
- if (f) {
36
- const m = t.getUniformLocation(r, f.name);
37
- m && s.set(f.name, m);
29
+ const c = e.getActiveAttrib(r, d);
30
+ c && n.set(c.name, e.getAttribLocation(r, c.name));
31
+ }
32
+ const f = /* @__PURE__ */ new Map(), m = e.getProgramParameter(r, e.ACTIVE_UNIFORMS);
33
+ for (let d = 0; d < m; d++) {
34
+ const c = e.getActiveUniform(r, d);
35
+ if (c) {
36
+ const h = e.getUniformLocation(r, c.name);
37
+ h && f.set(c.name, h);
38
38
  }
39
39
  }
40
- return { program: r, attribLocations: c, uniformLocations: s };
40
+ return { program: r, attribLocations: n, uniformLocations: f };
41
41
  }
42
- function M(t, o, n) {
43
- for (const [i, e] of Object.entries(n)) {
44
- const r = o.uniformLocations.get(i);
42
+ function L(e, o, a) {
43
+ for (const [t, s] of Object.entries(a)) {
44
+ const r = o.uniformLocations.get(t);
45
45
  if (r) {
46
- if (typeof e == "number")
47
- t.uniform1f(r, e);
48
- else if (Array.isArray(e))
49
- switch (e.length) {
46
+ if (typeof s == "number")
47
+ e.uniform1f(r, s);
48
+ else if (Array.isArray(s))
49
+ switch (s.length) {
50
50
  case 2:
51
- t.uniform2fv(r, e);
51
+ e.uniform2fv(r, s);
52
52
  break;
53
53
  case 3:
54
- t.uniform3fv(r, e);
54
+ e.uniform3fv(r, s);
55
55
  break;
56
56
  case 4:
57
- t.uniform4fv(r, e);
57
+ e.uniform4fv(r, s);
58
58
  break;
59
59
  }
60
60
  }
61
61
  }
62
62
  }
63
- function P(t, o) {
64
- const n = t.createTexture();
65
- if (!n) throw new Error("Failed to create texture");
66
- return t.bindTexture(t.TEXTURE_2D, n), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, t.RGBA, t.UNSIGNED_BYTE, o), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, t.LINEAR), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, t.LINEAR), { texture: n, width: o.naturalWidth, height: o.naturalHeight };
63
+ function M(e, o) {
64
+ const a = e.createTexture();
65
+ if (!a) throw new Error("Failed to create texture");
66
+ return e.bindTexture(e.TEXTURE_2D, a), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, o), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.LINEAR), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.LINEAR), { texture: a, width: o.naturalWidth, height: o.naturalHeight };
67
67
  }
68
- function O(t, o) {
69
- const n = new Float32Array([
68
+ function z(e, o) {
69
+ const a = new Float32Array([
70
70
  // pos.x pos.y tex.s tex.t
71
71
  -1,
72
72
  -1,
@@ -84,16 +84,16 @@ function O(t, o) {
84
84
  1,
85
85
  1,
86
86
  0
87
- ]), i = t.createBuffer();
88
- if (!i) throw new Error("Failed to create buffer");
89
- t.bindBuffer(t.ARRAY_BUFFER, i), t.bufferData(t.ARRAY_BUFFER, n, t.STATIC_DRAW);
90
- const e = 4 * Float32Array.BYTES_PER_ELEMENT, r = o.attribLocations.get("a_position");
91
- r !== void 0 && r !== -1 && (t.enableVertexAttribArray(r), t.vertexAttribPointer(r, 2, t.FLOAT, !1, e, 0));
92
- const c = o.attribLocations.get("a_texCoord");
93
- return c !== void 0 && c !== -1 && (t.enableVertexAttribArray(c), t.vertexAttribPointer(c, 2, t.FLOAT, !1, e, 2 * Float32Array.BYTES_PER_ELEMENT)), i;
87
+ ]), t = e.createBuffer();
88
+ if (!t) throw new Error("Failed to create buffer");
89
+ e.bindBuffer(e.ARRAY_BUFFER, t), e.bufferData(e.ARRAY_BUFFER, a, e.STATIC_DRAW);
90
+ const s = 4 * Float32Array.BYTES_PER_ELEMENT, r = o.attribLocations.get("a_position");
91
+ r !== void 0 && r !== -1 && (e.enableVertexAttribArray(r), e.vertexAttribPointer(r, 2, e.FLOAT, !1, s, 0));
92
+ const n = o.attribLocations.get("a_texCoord");
93
+ return n !== void 0 && n !== -1 && (e.enableVertexAttribArray(n), e.vertexAttribPointer(n, 2, e.FLOAT, !1, s, 2 * Float32Array.BYTES_PER_ELEMENT)), t;
94
94
  }
95
- function I(t) {
96
- t.drawArrays(t.TRIANGLE_STRIP, 0, 4);
95
+ function P(e) {
96
+ e.drawArrays(e.TRIANGLE_STRIP, 0, 4);
97
97
  }
98
98
  const V = `precision mediump float;
99
99
 
@@ -189,7 +189,7 @@ void main() {
189
189
  gl_Position = vec4(a_position, 0.0, 1.0);
190
190
  v_texCoord = a_texCoord;
191
191
  }
192
- `, W = {
192
+ `, I = {
193
193
  name: "halftone-cmyk",
194
194
  fragmentShader: V,
195
195
  vertexShader: b,
@@ -248,7 +248,7 @@ void main() {
248
248
 
249
249
  gl_FragColor = vec4(result, color.a);
250
250
  }
251
- `, F = {
251
+ `, O = {
252
252
  name: "halftone-duotone",
253
253
  fragmentShader: N,
254
254
  vertexShader: b,
@@ -258,7 +258,7 @@ void main() {
258
258
  { name: "u_duotoneColor", type: "vec3", default: [0, 0.6, 0.8], attribute: "duotone-color" },
259
259
  { name: "u_angle", type: "float", default: 0, attribute: "angle" }
260
260
  ]
261
- }, B = `precision mediump float;
261
+ }, F = `precision mediump float;
262
262
 
263
263
  varying vec2 v_texCoord;
264
264
 
@@ -314,9 +314,9 @@ void main() {
314
314
 
315
315
  gl_FragColor = vec4(result, 1.0);
316
316
  }
317
- `, Y = {
317
+ `, W = {
318
318
  name: "dot-grid",
319
- fragmentShader: B,
319
+ fragmentShader: F,
320
320
  vertexShader: b,
321
321
  uniforms: [
322
322
  { name: "u_dotRadius", type: "float", default: 4, attribute: "dot-radius" },
@@ -325,7 +325,7 @@ void main() {
325
325
  { name: "u_bgColor", type: "vec3", default: [1, 1, 1], attribute: "bg-color" },
326
326
  { name: "u_angle", type: "float", default: 0, attribute: "angle" }
327
327
  ]
328
- }, X = `precision mediump float;
328
+ }, Y = `precision mediump float;
329
329
 
330
330
  varying vec2 v_texCoord;
331
331
 
@@ -408,9 +408,9 @@ void main() {
408
408
 
409
409
  gl_FragColor = vec4(clamp(result, 0.0, 1.0), color.a);
410
410
  }
411
- `, $ = {
411
+ `, B = {
412
412
  name: "technicolor-2strip",
413
- fragmentShader: X,
413
+ fragmentShader: Y,
414
414
  vertexShader: b,
415
415
  uniforms: [
416
416
  { name: "u_dotRadius", type: "float", default: 7, attribute: "dot-radius" },
@@ -426,32 +426,32 @@ void main() {
426
426
  { name: "u_blendMode", type: "float", default: 1, attribute: "blend-mode" },
427
427
  { name: "u_intensityK", type: "float", default: 1, attribute: "intensity-k" }
428
428
  ]
429
- }, C = /* @__PURE__ */ new Map();
430
- function v(t) {
431
- C.set(t.name, t);
429
+ }, R = /* @__PURE__ */ new Map();
430
+ function v(e) {
431
+ R.set(e.name, e);
432
432
  }
433
- function G(t) {
434
- return C.get(t);
433
+ function X(e) {
434
+ return R.get(e);
435
435
  }
436
- function Z() {
437
- return Array.from(C.keys());
436
+ function Q() {
437
+ return Array.from(R.keys());
438
438
  }
439
+ v(I);
440
+ v(O);
439
441
  v(W);
440
- v(F);
441
- v(Y);
442
- v($);
443
- var H = Object.defineProperty, l = (t, o, n, i) => {
444
- for (var e = void 0, r = t.length - 1, c; r >= 0; r--)
445
- (c = t[r]) && (e = c(o, n, e) || e);
446
- return e && H(o, n, e), e;
442
+ v(B);
443
+ var G = Object.defineProperty, l = (e, o, a, t) => {
444
+ for (var s = void 0, r = e.length - 1, n; r >= 0; r--)
445
+ (n = e[r]) && (s = n(o, a, s) || s);
446
+ return s && G(o, a, s), s;
447
447
  };
448
- const q = 2;
449
- let A = Promise.resolve();
450
- function U(t) {
451
- const o = A.then(t, t);
452
- return A = o, o;
448
+ const $ = 2;
449
+ let T = Promise.resolve();
450
+ function w(e) {
451
+ const o = T.then(e, e);
452
+ return T = o, o;
453
453
  }
454
- const j = /* @__PURE__ */ new Set([
454
+ const H = /* @__PURE__ */ new Set([
455
455
  "effect",
456
456
  "dotRadius",
457
457
  "gridSize",
@@ -475,38 +475,32 @@ const j = /* @__PURE__ */ new Set([
475
475
  "showCool",
476
476
  "warmColor",
477
477
  "coolColor",
478
- "blendMode"
479
- ]), R = class R extends k {
478
+ "blendMode",
479
+ "referenceWidth"
480
+ ]), S = class S extends U {
480
481
  constructor() {
481
- super(...arguments), this.src = "", this.effect = "halftone-cmyk", this.dotRadius = 4, this.gridSize = 8, this.angleC = 15, this.angleM = 75, this.angleY = 0, this.angleK = 45, this.showC = 1, this.showM = 1, this.showY = 1, this.showK = 1, this.intensityK = 1, this.duotoneColor = "#0099cc", this.angle = 0, this.dotOffsetX = 0.5, this.dotOffsetY = 0.5, this.bgColor = "#ffffff", this.angleWarm = 15, this.angleCool = 75, this.showWarm = 1, this.showCool = 1, this.warmColor = "#d94010", this.coolColor = "#0da699", this.blendMode = 1, this.loadingBlur = 0, this._webglAvailable = !0, this._snapshotUrl = "", this._snapshotLoaded = !1, this._image = null, this._observer = null, this._resizeObserver = null, this._lastClientWidth = 0, this._visible = !1, this._needsRender = !1;
482
+ super(...arguments), this.src = "", this.effect = "halftone-cmyk", this.dotRadius = 4, this.gridSize = 8, this.angleC = 15, this.angleM = 75, this.angleY = 0, this.angleK = 45, this.showC = 1, this.showM = 1, this.showY = 1, this.showK = 1, this.intensityK = 1, this.duotoneColor = "#0099cc", this.angle = 0, this.dotOffsetX = 0.5, this.dotOffsetY = 0.5, this.bgColor = "#ffffff", this.angleWarm = 15, this.angleCool = 75, this.showWarm = 1, this.showCool = 1, this.warmColor = "#d94010", this.coolColor = "#0da699", this.blendMode = 1, this.referenceWidth = 1024, this._webglAvailable = !0, this._snapshotUrl = "", this._snapshotLoaded = !1, this._image = null, this._observer = null, this._visible = !1, this._needsRender = !1;
482
483
  }
483
484
  render() {
484
- if (!this._webglAvailable)
485
- return y`<img src=${this.src} alt="" />`;
486
- const o = this.loadingBlur > 0 ? `filter: blur(${this.loadingBlur}px)` : "";
487
- return y`
488
- <img src=${this.src} alt="" style=${o} />
485
+ return this._webglAvailable ? y`
486
+ <img class="base" src=${this.src} alt="" />
489
487
  ${this._snapshotUrl ? y`<img
490
488
  class="snapshot${this._snapshotLoaded ? " loaded" : ""}"
491
489
  src=${this._snapshotUrl}
492
490
  @load=${this._onSnapshotLoad}
493
491
  alt="" />` : ""}
494
- `;
492
+ ` : y`<img src=${this.src} alt="" />`;
495
493
  }
496
494
  connectedCallback() {
497
495
  super.connectedCallback(), this._observer = new IntersectionObserver(
498
496
  (o) => {
499
- var i;
500
- const n = this._visible;
501
- this._visible = ((i = o[0]) == null ? void 0 : i.isIntersecting) ?? !1, this._visible && !n && this._needsRender && (this._needsRender = !1, U(() => this._renderEffect()));
497
+ var t;
498
+ const a = this._visible;
499
+ this._visible = ((t = o[0]) == null ? void 0 : t.isIntersecting) ?? !1, this._visible && !a && (this._needsRender || this._image && !this._snapshotUrl) && (this._needsRender = !1, w(() => this._renderEffect()));
502
500
  },
503
501
  // Start rendering slightly before the element scrolls into view.
504
502
  { rootMargin: "200px" }
505
- ), this._observer.observe(this), this._resizeObserver = new ResizeObserver(() => {
506
- if (!this._image) return;
507
- const o = this.clientWidth;
508
- o > 0 && o !== this._lastClientWidth && (this._lastClientWidth = o, this._scheduleRender());
509
- }), this._resizeObserver.observe(this);
503
+ ), this._observer.observe(this);
510
504
  }
511
505
  updated(o) {
512
506
  if (o.has("src") && this.src) {
@@ -515,29 +509,34 @@ const j = /* @__PURE__ */ new Set([
515
509
  }
516
510
  if (!this._image) return;
517
511
  [...o.keys()].some(
518
- (i) => j.has(i)
512
+ (t) => H.has(t)
519
513
  ) && this._scheduleRender();
520
514
  }
521
515
  disconnectedCallback() {
522
- var o, n;
523
- super.disconnectedCallback(), (o = this._observer) == null || o.disconnect(), (n = this._resizeObserver) == null || n.disconnect(), this._revokeSnapshot();
516
+ var o;
517
+ super.disconnectedCallback(), (o = this._observer) == null || o.disconnect(), this._revokeSnapshot();
524
518
  }
525
519
  // ---------------------------------------------------------------------------
526
520
  // Image loading
527
521
  // ---------------------------------------------------------------------------
528
522
  _loadImage(o) {
529
- const n = new Image();
530
- n.crossOrigin = "anonymous", n.onload = () => {
531
- this._image = n, this._scheduleRender();
532
- }, n.onerror = () => {
523
+ const a = new Image();
524
+ a.crossOrigin = "anonymous", a.onload = () => {
525
+ this._image = a, this._scheduleRender();
526
+ }, a.onerror = () => {
533
527
  console.warn(`[some-shade] Failed to load image: ${o}`);
534
- }, n.src = o;
528
+ }, a.src = o;
535
529
  }
536
530
  // ---------------------------------------------------------------------------
537
531
  // Render scheduling
538
532
  // ---------------------------------------------------------------------------
539
533
  _scheduleRender() {
540
- this._visible ? U(() => this._renderEffect()) : this._needsRender = !0;
534
+ this._visible ? w(() => this._renderEffect()) : (this._needsRender = !0, requestAnimationFrame(() => {
535
+ if (this._needsRender && !this._visible) {
536
+ const o = this.getBoundingClientRect();
537
+ o.bottom >= 0 && o.top < window.innerHeight && (this._visible = !0, this._needsRender = !1, w(() => this._renderEffect()));
538
+ }
539
+ }));
541
540
  }
542
541
  // ---------------------------------------------------------------------------
543
542
  // WebGL render → snapshot → tear-down
@@ -545,52 +544,50 @@ const j = /* @__PURE__ */ new Set([
545
544
  async _renderEffect() {
546
545
  var _;
547
546
  if (!this._image) return;
548
- const o = G(this.effect);
547
+ const o = X(this.effect);
549
548
  if (!o) {
550
549
  console.warn(`[some-shade] Unknown effect: ${this.effect}`);
551
550
  return;
552
551
  }
553
- const n = Math.min(window.devicePixelRatio || 1, q), i = this._image.naturalWidth, e = this._image.naturalHeight, r = this.clientWidth || i, c = Math.max(1, i / r);
554
- this._lastClientWidth = this.clientWidth;
555
- const h = document.createElement("canvas");
556
- h.width = i * n, h.height = e * n;
557
- const s = L(h);
558
- if (!s) {
552
+ const a = Math.min(window.devicePixelRatio || 1, $), t = this._image.naturalWidth, s = this._image.naturalHeight, r = document.createElement("canvas");
553
+ r.width = t * a, r.height = s * a;
554
+ const n = k(r);
555
+ if (!n) {
559
556
  this._webglAvailable = !1;
560
557
  return;
561
558
  }
562
559
  try {
563
- const d = z(
564
- s,
560
+ const f = D(
561
+ n,
565
562
  o.vertexShader,
566
563
  o.fragmentShader
567
564
  );
568
- s.useProgram(d.program);
569
- const f = P(s, this._image), m = O(s, d);
570
- s.viewport(0, 0, h.width, h.height), s.clearColor(0, 0, 0, 0), s.clear(s.COLOR_BUFFER_BIT), s.activeTexture(s.TEXTURE0), s.bindTexture(s.TEXTURE_2D, f.texture);
571
- const S = d.uniformLocations.get("u_image");
572
- S && s.uniform1i(S, 0), M(
573
- s,
574
- d,
575
- this._getUniformValues(f, n, c)
576
- ), s.bindBuffer(s.ARRAY_BUFFER, m);
577
- const x = 4 * Float32Array.BYTES_PER_ELEMENT, g = d.attribLocations.get("a_position");
578
- g !== void 0 && g !== -1 && (s.enableVertexAttribArray(g), s.vertexAttribPointer(g, 2, s.FLOAT, !1, x, 0));
579
- const p = d.attribLocations.get("a_texCoord");
580
- p !== void 0 && p !== -1 && (s.enableVertexAttribArray(p), s.vertexAttribPointer(
565
+ n.useProgram(f.program);
566
+ const m = M(n, this._image), d = z(n, f);
567
+ n.viewport(0, 0, r.width, r.height), n.clearColor(0, 0, 0, 0), n.clear(n.COLOR_BUFFER_BIT), n.activeTexture(n.TEXTURE0), n.bindTexture(n.TEXTURE_2D, m.texture);
568
+ const c = f.uniformLocations.get("u_image");
569
+ c && n.uniform1i(c, 0), L(
570
+ n,
571
+ f,
572
+ this._getUniformValues(m, a)
573
+ ), n.bindBuffer(n.ARRAY_BUFFER, d);
574
+ const h = 4 * Float32Array.BYTES_PER_ELEMENT, g = f.attribLocations.get("a_position");
575
+ g !== void 0 && g !== -1 && (n.enableVertexAttribArray(g), n.vertexAttribPointer(g, 2, n.FLOAT, !1, h, 0));
576
+ const p = f.attribLocations.get("a_texCoord");
577
+ p !== void 0 && p !== -1 && (n.enableVertexAttribArray(p), n.vertexAttribPointer(
581
578
  p,
582
579
  2,
583
- s.FLOAT,
580
+ n.FLOAT,
584
581
  !1,
585
- x,
582
+ h,
586
583
  2 * Float32Array.BYTES_PER_ELEMENT
587
- )), I(s);
584
+ )), P(n);
588
585
  const E = await new Promise(
589
- (K) => h.toBlob(K)
586
+ (A) => r.toBlob(A)
590
587
  );
591
- s.deleteTexture(f.texture), s.deleteProgram(d.program), s.deleteBuffer(m), E && (this._snapshotLoaded = !1, this._revokeSnapshot(), this._snapshotUrl = URL.createObjectURL(E));
588
+ n.deleteTexture(m.texture), n.deleteProgram(f.program), n.deleteBuffer(d), E && (this._snapshotLoaded = !1, this._revokeSnapshot(), this._snapshotUrl = URL.createObjectURL(E));
592
589
  } finally {
593
- (_ = s.getExtension("WEBGL_lose_context")) == null || _.loseContext();
590
+ (_ = n.getExtension("WEBGL_lose_context")) == null || _.loseContext();
594
591
  }
595
592
  }
596
593
  // ---------------------------------------------------------------------------
@@ -611,19 +608,21 @@ const j = /* @__PURE__ */ new Set([
611
608
  _revokeSnapshot() {
612
609
  this._snapshotUrl && (URL.revokeObjectURL(this._snapshotUrl), this._snapshotUrl = "");
613
610
  }
614
- _getUniformValues(o, n, i) {
615
- const e = {};
616
- return e.u_resolution = [
617
- o.width * n,
618
- o.height * n
619
- ], e.u_dotRadius = this.dotRadius * i, e.u_gridSize = this.gridSize * i, this.effect === "halftone-cmyk" ? (e.u_angleC = this.angleC, e.u_angleM = this.angleM, e.u_angleY = this.angleY, e.u_angleK = this.angleK, e.u_showC = this.showC, e.u_showM = this.showM, e.u_showY = this.showY, e.u_showK = this.showK, e.u_intensityK = this.intensityK) : this.effect === "halftone-duotone" ? (e.u_duotoneColor = this._parseHexColor(this.duotoneColor), e.u_angle = this.angle) : this.effect === "dot-grid" ? (e.u_dotOffset = [this.dotOffsetX, this.dotOffsetY], e.u_bgColor = this._parseHexColor(this.bgColor), e.u_angle = this.angle) : this.effect === "technicolor-2strip" && (e.u_angleWarm = this.angleWarm, e.u_angleCool = this.angleCool, e.u_angleK = this.angleK, e.u_showWarm = this.showWarm, e.u_showCool = this.showCool, e.u_showK = this.showK, e.u_warmColor = this._parseHexColor(this.warmColor), e.u_coolColor = this._parseHexColor(this.coolColor), e.u_blendMode = this.blendMode, e.u_intensityK = this.intensityK), e;
611
+ _getUniformValues(o, a) {
612
+ const t = {};
613
+ t.u_resolution = [
614
+ o.width * a,
615
+ o.height * a
616
+ ];
617
+ const s = o.width / this.referenceWidth;
618
+ return t.u_dotRadius = this.dotRadius * s, t.u_gridSize = this.gridSize * s, this.effect === "halftone-cmyk" ? (t.u_angleC = this.angleC, t.u_angleM = this.angleM, t.u_angleY = this.angleY, t.u_angleK = this.angleK, t.u_showC = this.showC, t.u_showM = this.showM, t.u_showY = this.showY, t.u_showK = this.showK, t.u_intensityK = this.intensityK) : this.effect === "halftone-duotone" ? (t.u_duotoneColor = this._parseHexColor(this.duotoneColor), t.u_angle = this.angle) : this.effect === "dot-grid" ? (t.u_dotOffset = [this.dotOffsetX, this.dotOffsetY], t.u_bgColor = this._parseHexColor(this.bgColor), t.u_angle = this.angle) : this.effect === "technicolor-2strip" && (t.u_angleWarm = this.angleWarm, t.u_angleCool = this.angleCool, t.u_angleK = this.angleK, t.u_showWarm = this.showWarm, t.u_showCool = this.showCool, t.u_showK = this.showK, t.u_warmColor = this._parseHexColor(this.warmColor), t.u_coolColor = this._parseHexColor(this.coolColor), t.u_blendMode = this.blendMode, t.u_intensityK = this.intensityK), t;
620
619
  }
621
620
  _parseHexColor(o) {
622
- const n = o.replace("#", ""), i = parseInt(n.substring(0, 2), 16) / 255, e = parseInt(n.substring(2, 4), 16) / 255, r = parseInt(n.substring(4, 6), 16) / 255;
623
- return [i, e, r];
621
+ const a = o.replace("#", ""), t = parseInt(a.substring(0, 2), 16) / 255, s = parseInt(a.substring(2, 4), 16) / 255, r = parseInt(a.substring(4, 6), 16) / 255;
622
+ return [t, s, r];
624
623
  }
625
624
  };
626
- R.styles = D`
625
+ S.styles = K`
627
626
  :host {
628
627
  display: block;
629
628
  position: relative;
@@ -635,6 +634,9 @@ R.styles = D`
635
634
  width: 100%;
636
635
  height: auto;
637
636
  }
637
+ img.base {
638
+ opacity: 0;
639
+ }
638
640
  img.snapshot {
639
641
  position: absolute;
640
642
  inset: 0;
@@ -647,98 +649,98 @@ R.styles = D`
647
649
  opacity: 1;
648
650
  }
649
651
  `;
650
- let a = R;
652
+ let i = S;
651
653
  l([
652
654
  u()
653
- ], a.prototype, "src");
655
+ ], i.prototype, "src");
654
656
  l([
655
657
  u()
656
- ], a.prototype, "effect");
658
+ ], i.prototype, "effect");
657
659
  l([
658
660
  u({ type: Number, attribute: "dot-radius" })
659
- ], a.prototype, "dotRadius");
661
+ ], i.prototype, "dotRadius");
660
662
  l([
661
663
  u({ type: Number, attribute: "grid-size" })
662
- ], a.prototype, "gridSize");
664
+ ], i.prototype, "gridSize");
663
665
  l([
664
666
  u({ type: Number, attribute: "angle-c" })
665
- ], a.prototype, "angleC");
667
+ ], i.prototype, "angleC");
666
668
  l([
667
669
  u({ type: Number, attribute: "angle-m" })
668
- ], a.prototype, "angleM");
670
+ ], i.prototype, "angleM");
669
671
  l([
670
672
  u({ type: Number, attribute: "angle-y" })
671
- ], a.prototype, "angleY");
673
+ ], i.prototype, "angleY");
672
674
  l([
673
675
  u({ type: Number, attribute: "angle-k" })
674
- ], a.prototype, "angleK");
676
+ ], i.prototype, "angleK");
675
677
  l([
676
678
  u({ type: Number, attribute: "show-c" })
677
- ], a.prototype, "showC");
679
+ ], i.prototype, "showC");
678
680
  l([
679
681
  u({ type: Number, attribute: "show-m" })
680
- ], a.prototype, "showM");
682
+ ], i.prototype, "showM");
681
683
  l([
682
684
  u({ type: Number, attribute: "show-y" })
683
- ], a.prototype, "showY");
685
+ ], i.prototype, "showY");
684
686
  l([
685
687
  u({ type: Number, attribute: "show-k" })
686
- ], a.prototype, "showK");
688
+ ], i.prototype, "showK");
687
689
  l([
688
690
  u({ type: Number, attribute: "intensity-k" })
689
- ], a.prototype, "intensityK");
691
+ ], i.prototype, "intensityK");
690
692
  l([
691
693
  u({ attribute: "duotone-color" })
692
- ], a.prototype, "duotoneColor");
694
+ ], i.prototype, "duotoneColor");
693
695
  l([
694
696
  u({ type: Number })
695
- ], a.prototype, "angle");
697
+ ], i.prototype, "angle");
696
698
  l([
697
699
  u({ type: Number, attribute: "dot-offset-x" })
698
- ], a.prototype, "dotOffsetX");
700
+ ], i.prototype, "dotOffsetX");
699
701
  l([
700
702
  u({ type: Number, attribute: "dot-offset-y" })
701
- ], a.prototype, "dotOffsetY");
703
+ ], i.prototype, "dotOffsetY");
702
704
  l([
703
705
  u({ attribute: "bg-color" })
704
- ], a.prototype, "bgColor");
706
+ ], i.prototype, "bgColor");
705
707
  l([
706
708
  u({ type: Number, attribute: "angle-warm" })
707
- ], a.prototype, "angleWarm");
709
+ ], i.prototype, "angleWarm");
708
710
  l([
709
711
  u({ type: Number, attribute: "angle-cool" })
710
- ], a.prototype, "angleCool");
712
+ ], i.prototype, "angleCool");
711
713
  l([
712
714
  u({ type: Number, attribute: "show-warm" })
713
- ], a.prototype, "showWarm");
715
+ ], i.prototype, "showWarm");
714
716
  l([
715
717
  u({ type: Number, attribute: "show-cool" })
716
- ], a.prototype, "showCool");
718
+ ], i.prototype, "showCool");
717
719
  l([
718
720
  u({ attribute: "warm-color" })
719
- ], a.prototype, "warmColor");
721
+ ], i.prototype, "warmColor");
720
722
  l([
721
723
  u({ attribute: "cool-color" })
722
- ], a.prototype, "coolColor");
724
+ ], i.prototype, "coolColor");
723
725
  l([
724
726
  u({ type: Number, attribute: "blend-mode" })
725
- ], a.prototype, "blendMode");
727
+ ], i.prototype, "blendMode");
726
728
  l([
727
- u({ type: Number, attribute: "loading-blur" })
728
- ], a.prototype, "loadingBlur");
729
+ u({ type: Number, attribute: "reference-width" })
730
+ ], i.prototype, "referenceWidth");
729
731
  l([
730
- w()
731
- ], a.prototype, "_webglAvailable");
732
+ C()
733
+ ], i.prototype, "_webglAvailable");
732
734
  l([
733
- w()
734
- ], a.prototype, "_snapshotUrl");
735
+ C()
736
+ ], i.prototype, "_snapshotUrl");
735
737
  l([
736
- w()
737
- ], a.prototype, "_snapshotLoaded");
738
- customElements.get("some-shade-image") || customElements.define("some-shade-image", a);
738
+ C()
739
+ ], i.prototype, "_snapshotLoaded");
740
+ customElements.get("some-shade-image") || customElements.define("some-shade-image", i);
739
741
  export {
740
- a as SomeShadeImage,
741
- G as get,
742
- Z as list,
742
+ i as SomeShadeImage,
743
+ X as get,
744
+ Q as list,
743
745
  v as register
744
746
  };
@@ -1,4 +1,4 @@
1
- (function(c,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("lit"),require("lit/decorators.js")):typeof define=="function"&&define.amd?define(["exports","lit","lit/decorators.js"],m):(c=typeof globalThis<"u"?globalThis:c||self,m(c.SomeShade={},c.Lit,c.LitDecorators))})(this,(function(c,m,l){"use strict";function k(e){return e.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!0})}function S(e,o,n){const i=e.createShader(o);if(!i)throw new Error("Failed to create shader");if(e.shaderSource(i,n),e.compileShader(i),!e.getShaderParameter(i,e.COMPILE_STATUS)){const t=e.getShaderInfoLog(i);throw e.deleteShader(i),new Error(`Shader compile error: ${t}`)}return i}function D(e,o,n){const i=S(e,e.VERTEX_SHADER,o),t=S(e,e.FRAGMENT_SHADER,n),a=e.createProgram();if(!a)throw new Error("Failed to create program");if(e.attachShader(a,i),e.attachShader(a,t),e.linkProgram(a),!e.getProgramParameter(a,e.LINK_STATUS)){const d=e.getProgramInfoLog(a);throw e.deleteProgram(a),new Error(`Program link error: ${d}`)}e.deleteShader(i),e.deleteShader(t);const f=new Map,p=e.getProgramParameter(a,e.ACTIVE_ATTRIBUTES);for(let d=0;d<p;d++){const h=e.getActiveAttrib(a,d);h&&f.set(h.name,e.getAttribLocation(a,h.name))}const s=new Map,v=e.getProgramParameter(a,e.ACTIVE_UNIFORMS);for(let d=0;d<v;d++){const h=e.getActiveUniform(a,d);if(h){const g=e.getUniformLocation(a,h.name);g&&s.set(h.name,g)}}return{program:a,attribLocations:f,uniformLocations:s}}function L(e,o,n){for(const[i,t]of Object.entries(n)){const a=o.uniformLocations.get(i);if(a){if(typeof t=="number")e.uniform1f(a,t);else if(Array.isArray(t))switch(t.length){case 2:e.uniform2fv(a,t);break;case 3:e.uniform3fv(a,t);break;case 4:e.uniform4fv(a,t);break}}}}function z(e,o){const n=e.createTexture();if(!n)throw new Error("Failed to create texture");return e.bindTexture(e.TEXTURE_2D,n),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,o),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),{texture:n,width:o.naturalWidth,height:o.naturalHeight}}function M(e,o){const n=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,1,1,1,0]),i=e.createBuffer();if(!i)throw new Error("Failed to create buffer");e.bindBuffer(e.ARRAY_BUFFER,i),e.bufferData(e.ARRAY_BUFFER,n,e.STATIC_DRAW);const t=4*Float32Array.BYTES_PER_ELEMENT,a=o.attribLocations.get("a_position");a!==void 0&&a!==-1&&(e.enableVertexAttribArray(a),e.vertexAttribPointer(a,2,e.FLOAT,!1,t,0));const f=o.attribLocations.get("a_texCoord");return f!==void 0&&f!==-1&&(e.enableVertexAttribArray(f),e.vertexAttribPointer(f,2,e.FLOAT,!1,t,2*Float32Array.BYTES_PER_ELEMENT)),i}function P(e){e.drawArrays(e.TRIANGLE_STRIP,0,4)}const O=`precision mediump float;
1
+ (function(d,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("lit"),require("lit/decorators.js")):typeof define=="function"&&define.amd?define(["exports","lit","lit/decorators.js"],m):(d=typeof globalThis<"u"?globalThis:d||self,m(d.SomeShade={},d.Lit,d.LitDecorators))})(this,(function(d,m,s){"use strict";function U(e){return e.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,preserveDrawingBuffer:!0})}function E(e,o,a){const t=e.createShader(o);if(!t)throw new Error("Failed to create shader");if(e.shaderSource(t,a),e.compileShader(t),!e.getShaderParameter(t,e.COMPILE_STATUS)){const u=e.getShaderInfoLog(t);throw e.deleteShader(t),new Error(`Shader compile error: ${u}`)}return t}function K(e,o,a){const t=E(e,e.VERTEX_SHADER,o),u=E(e,e.FRAGMENT_SHADER,a),r=e.createProgram();if(!r)throw new Error("Failed to create program");if(e.attachShader(r,t),e.attachShader(r,u),e.linkProgram(r),!e.getProgramParameter(r,e.LINK_STATUS)){const f=e.getProgramInfoLog(r);throw e.deleteProgram(r),new Error(`Program link error: ${f}`)}e.deleteShader(t),e.deleteShader(u);const n=new Map,v=e.getProgramParameter(r,e.ACTIVE_ATTRIBUTES);for(let f=0;f<v;f++){const h=e.getActiveAttrib(r,f);h&&n.set(h.name,e.getAttribLocation(r,h.name))}const c=new Map,_=e.getProgramParameter(r,e.ACTIVE_UNIFORMS);for(let f=0;f<_;f++){const h=e.getActiveUniform(r,f);if(h){const g=e.getUniformLocation(r,h.name);g&&c.set(h.name,g)}}return{program:r,attribLocations:n,uniformLocations:c}}function k(e,o,a){for(const[t,u]of Object.entries(a)){const r=o.uniformLocations.get(t);if(r){if(typeof u=="number")e.uniform1f(r,u);else if(Array.isArray(u))switch(u.length){case 2:e.uniform2fv(r,u);break;case 3:e.uniform3fv(r,u);break;case 4:e.uniform4fv(r,u);break}}}}function D(e,o){const a=e.createTexture();if(!a)throw new Error("Failed to create texture");return e.bindTexture(e.TEXTURE_2D,a),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,o),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),{texture:a,width:o.naturalWidth,height:o.naturalHeight}}function L(e,o){const a=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,1,1,1,0]),t=e.createBuffer();if(!t)throw new Error("Failed to create buffer");e.bindBuffer(e.ARRAY_BUFFER,t),e.bufferData(e.ARRAY_BUFFER,a,e.STATIC_DRAW);const u=4*Float32Array.BYTES_PER_ELEMENT,r=o.attribLocations.get("a_position");r!==void 0&&r!==-1&&(e.enableVertexAttribArray(r),e.vertexAttribPointer(r,2,e.FLOAT,!1,u,0));const n=o.attribLocations.get("a_texCoord");return n!==void 0&&n!==-1&&(e.enableVertexAttribArray(n),e.vertexAttribPointer(n,2,e.FLOAT,!1,u,2*Float32Array.BYTES_PER_ELEMENT)),t}function M(e){e.drawArrays(e.TRIANGLE_STRIP,0,4)}const z=`precision mediump float;
2
2
 
3
3
  varying vec2 v_texCoord;
4
4
 
@@ -92,7 +92,7 @@ void main() {
92
92
  gl_Position = vec4(a_position, 0.0, 1.0);
93
93
  v_texCoord = a_texCoord;
94
94
  }
95
- `,I={name:"halftone-cmyk",fragmentShader:O,vertexShader:b,uniforms:[{name:"u_dotRadius",type:"float",default:4,attribute:"dot-radius"},{name:"u_gridSize",type:"float",default:8,attribute:"grid-size"},{name:"u_angleC",type:"float",default:15,attribute:"angle-c"},{name:"u_angleM",type:"float",default:75,attribute:"angle-m"},{name:"u_angleY",type:"float",default:0,attribute:"angle-y"},{name:"u_angleK",type:"float",default:45,attribute:"angle-k"},{name:"u_showC",type:"float",default:1,attribute:"show-c"},{name:"u_showM",type:"float",default:1,attribute:"show-m"},{name:"u_showY",type:"float",default:1,attribute:"show-y"},{name:"u_showK",type:"float",default:1,attribute:"show-k"},{name:"u_intensityK",type:"float",default:1,attribute:"intensity-k"}]},V={name:"halftone-duotone",fragmentShader:`precision mediump float;
95
+ `,P={name:"halftone-cmyk",fragmentShader:z,vertexShader:b,uniforms:[{name:"u_dotRadius",type:"float",default:4,attribute:"dot-radius"},{name:"u_gridSize",type:"float",default:8,attribute:"grid-size"},{name:"u_angleC",type:"float",default:15,attribute:"angle-c"},{name:"u_angleM",type:"float",default:75,attribute:"angle-m"},{name:"u_angleY",type:"float",default:0,attribute:"angle-y"},{name:"u_angleK",type:"float",default:45,attribute:"angle-k"},{name:"u_showC",type:"float",default:1,attribute:"show-c"},{name:"u_showM",type:"float",default:1,attribute:"show-m"},{name:"u_showY",type:"float",default:1,attribute:"show-y"},{name:"u_showK",type:"float",default:1,attribute:"show-k"},{name:"u_intensityK",type:"float",default:1,attribute:"intensity-k"}]},V={name:"halftone-duotone",fragmentShader:`precision mediump float;
96
96
 
97
97
  varying vec2 v_texCoord;
98
98
 
@@ -134,7 +134,7 @@ void main() {
134
134
 
135
135
  gl_FragColor = vec4(result, color.a);
136
136
  }
137
- `,vertexShader:b,uniforms:[{name:"u_dotRadius",type:"float",default:4,attribute:"dot-radius"},{name:"u_gridSize",type:"float",default:8,attribute:"grid-size"},{name:"u_duotoneColor",type:"vec3",default:[0,.6,.8],attribute:"duotone-color"},{name:"u_angle",type:"float",default:0,attribute:"angle"}]},W={name:"dot-grid",fragmentShader:`precision mediump float;
137
+ `,vertexShader:b,uniforms:[{name:"u_dotRadius",type:"float",default:4,attribute:"dot-radius"},{name:"u_gridSize",type:"float",default:8,attribute:"grid-size"},{name:"u_duotoneColor",type:"vec3",default:[0,.6,.8],attribute:"duotone-color"},{name:"u_angle",type:"float",default:0,attribute:"angle"}]},I={name:"dot-grid",fragmentShader:`precision mediump float;
138
138
 
139
139
  varying vec2 v_texCoord;
140
140
 
@@ -190,7 +190,7 @@ void main() {
190
190
 
191
191
  gl_FragColor = vec4(result, 1.0);
192
192
  }
193
- `,vertexShader:b,uniforms:[{name:"u_dotRadius",type:"float",default:4,attribute:"dot-radius"},{name:"u_gridSize",type:"float",default:8,attribute:"grid-size"},{name:"u_dotOffset",type:"vec2",default:[.5,.5],attribute:"dot-offset"},{name:"u_bgColor",type:"vec3",default:[1,1,1],attribute:"bg-color"},{name:"u_angle",type:"float",default:0,attribute:"angle"}]},N={name:"technicolor-2strip",fragmentShader:`precision mediump float;
193
+ `,vertexShader:b,uniforms:[{name:"u_dotRadius",type:"float",default:4,attribute:"dot-radius"},{name:"u_gridSize",type:"float",default:8,attribute:"grid-size"},{name:"u_dotOffset",type:"vec2",default:[.5,.5],attribute:"dot-offset"},{name:"u_bgColor",type:"vec3",default:[1,1,1],attribute:"bg-color"},{name:"u_angle",type:"float",default:0,attribute:"angle"}]},O={name:"technicolor-2strip",fragmentShader:`precision mediump float;
194
194
 
195
195
  varying vec2 v_texCoord;
196
196
 
@@ -273,14 +273,14 @@ void main() {
273
273
 
274
274
  gl_FragColor = vec4(clamp(result, 0.0, 1.0), color.a);
275
275
  }
276
- `,vertexShader:b,uniforms:[{name:"u_dotRadius",type:"float",default:7,attribute:"dot-radius"},{name:"u_gridSize",type:"float",default:10,attribute:"grid-size"},{name:"u_angleWarm",type:"float",default:15,attribute:"angle-warm"},{name:"u_angleCool",type:"float",default:75,attribute:"angle-cool"},{name:"u_angleK",type:"float",default:45,attribute:"angle-k"},{name:"u_showWarm",type:"float",default:1,attribute:"show-warm"},{name:"u_showCool",type:"float",default:1,attribute:"show-cool"},{name:"u_showK",type:"float",default:1,attribute:"show-k"},{name:"u_warmColor",type:"vec3",default:[.85,.25,.06],attribute:"warm-color"},{name:"u_coolColor",type:"vec3",default:[.05,.65,.6],attribute:"cool-color"},{name:"u_blendMode",type:"float",default:1,attribute:"blend-mode"},{name:"u_intensityK",type:"float",default:1,attribute:"intensity-k"}]},C=new Map;function _(e){C.set(e.name,e)}function x(e){return C.get(e)}function F(){return Array.from(C.keys())}_(I),_(V),_(W),_(N);var B=Object.defineProperty,u=(e,o,n,i)=>{for(var t=void 0,a=e.length-1,f;a>=0;a--)(f=e[a])&&(t=f(o,n,t)||t);return t&&B(o,n,t),t};const Y=2;let E=Promise.resolve();function T(e){const o=E.then(e,e);return E=o,o}const X=new Set(["effect","dotRadius","gridSize","angleC","angleM","angleY","angleK","showC","showM","showY","showK","intensityK","duotoneColor","angle","dotOffsetX","dotOffsetY","bgColor","angleWarm","angleCool","showWarm","showCool","warmColor","coolColor","blendMode"]),R=class R extends m.LitElement{constructor(){super(...arguments),this.src="",this.effect="halftone-cmyk",this.dotRadius=4,this.gridSize=8,this.angleC=15,this.angleM=75,this.angleY=0,this.angleK=45,this.showC=1,this.showM=1,this.showY=1,this.showK=1,this.intensityK=1,this.duotoneColor="#0099cc",this.angle=0,this.dotOffsetX=.5,this.dotOffsetY=.5,this.bgColor="#ffffff",this.angleWarm=15,this.angleCool=75,this.showWarm=1,this.showCool=1,this.warmColor="#d94010",this.coolColor="#0da699",this.blendMode=1,this.loadingBlur=0,this._webglAvailable=!0,this._snapshotUrl="",this._snapshotLoaded=!1,this._image=null,this._observer=null,this._resizeObserver=null,this._lastClientWidth=0,this._visible=!1,this._needsRender=!1}render(){if(!this._webglAvailable)return m.html`<img src=${this.src} alt="" />`;const o=this.loadingBlur>0?`filter: blur(${this.loadingBlur}px)`:"";return m.html`
277
- <img src=${this.src} alt="" style=${o} />
276
+ `,vertexShader:b,uniforms:[{name:"u_dotRadius",type:"float",default:7,attribute:"dot-radius"},{name:"u_gridSize",type:"float",default:10,attribute:"grid-size"},{name:"u_angleWarm",type:"float",default:15,attribute:"angle-warm"},{name:"u_angleCool",type:"float",default:75,attribute:"angle-cool"},{name:"u_angleK",type:"float",default:45,attribute:"angle-k"},{name:"u_showWarm",type:"float",default:1,attribute:"show-warm"},{name:"u_showCool",type:"float",default:1,attribute:"show-cool"},{name:"u_showK",type:"float",default:1,attribute:"show-k"},{name:"u_warmColor",type:"vec3",default:[.85,.25,.06],attribute:"warm-color"},{name:"u_coolColor",type:"vec3",default:[.05,.65,.6],attribute:"cool-color"},{name:"u_blendMode",type:"float",default:1,attribute:"blend-mode"},{name:"u_intensityK",type:"float",default:1,attribute:"intensity-k"}]},C=new Map;function p(e){C.set(e.name,e)}function x(e){return C.get(e)}function N(){return Array.from(C.keys())}p(P),p(V),p(I),p(O);var F=Object.defineProperty,l=(e,o,a,t)=>{for(var u=void 0,r=e.length-1,n;r>=0;r--)(n=e[r])&&(u=n(o,a,u)||u);return u&&F(o,a,u),u};const W=2;let T=Promise.resolve();function R(e){const o=T.then(e,e);return T=o,o}const Y=new Set(["effect","dotRadius","gridSize","angleC","angleM","angleY","angleK","showC","showM","showY","showK","intensityK","duotoneColor","angle","dotOffsetX","dotOffsetY","bgColor","angleWarm","angleCool","showWarm","showCool","warmColor","coolColor","blendMode","referenceWidth"]),S=class S extends m.LitElement{constructor(){super(...arguments),this.src="",this.effect="halftone-cmyk",this.dotRadius=4,this.gridSize=8,this.angleC=15,this.angleM=75,this.angleY=0,this.angleK=45,this.showC=1,this.showM=1,this.showY=1,this.showK=1,this.intensityK=1,this.duotoneColor="#0099cc",this.angle=0,this.dotOffsetX=.5,this.dotOffsetY=.5,this.bgColor="#ffffff",this.angleWarm=15,this.angleCool=75,this.showWarm=1,this.showCool=1,this.warmColor="#d94010",this.coolColor="#0da699",this.blendMode=1,this.referenceWidth=1024,this._webglAvailable=!0,this._snapshotUrl="",this._snapshotLoaded=!1,this._image=null,this._observer=null,this._visible=!1,this._needsRender=!1}render(){return this._webglAvailable?m.html`
277
+ <img class="base" src=${this.src} alt="" />
278
278
  ${this._snapshotUrl?m.html`<img
279
279
  class="snapshot${this._snapshotLoaded?" loaded":""}"
280
280
  src=${this._snapshotUrl}
281
281
  @load=${this._onSnapshotLoad}
282
282
  alt="" />`:""}
283
- `}connectedCallback(){super.connectedCallback(),this._observer=new IntersectionObserver(o=>{var i;const n=this._visible;this._visible=((i=o[0])==null?void 0:i.isIntersecting)??!1,this._visible&&!n&&this._needsRender&&(this._needsRender=!1,T(()=>this._renderEffect()))},{rootMargin:"200px"}),this._observer.observe(this),this._resizeObserver=new ResizeObserver(()=>{if(!this._image)return;const o=this.clientWidth;o>0&&o!==this._lastClientWidth&&(this._lastClientWidth=o,this._scheduleRender())}),this._resizeObserver.observe(this)}updated(o){if(o.has("src")&&this.src){this._loadImage(this.src);return}if(!this._image)return;[...o.keys()].some(i=>X.has(i))&&this._scheduleRender()}disconnectedCallback(){var o,n;super.disconnectedCallback(),(o=this._observer)==null||o.disconnect(),(n=this._resizeObserver)==null||n.disconnect(),this._revokeSnapshot()}_loadImage(o){const n=new Image;n.crossOrigin="anonymous",n.onload=()=>{this._image=n,this._scheduleRender()},n.onerror=()=>{console.warn(`[some-shade] Failed to load image: ${o}`)},n.src=o}_scheduleRender(){this._visible?T(()=>this._renderEffect()):this._needsRender=!0}async _renderEffect(){var v;if(!this._image)return;const o=x(this.effect);if(!o){console.warn(`[some-shade] Unknown effect: ${this.effect}`);return}const n=Math.min(window.devicePixelRatio||1,Y),i=this._image.naturalWidth,t=this._image.naturalHeight,a=this.clientWidth||i,f=Math.max(1,i/a);this._lastClientWidth=this.clientWidth;const p=document.createElement("canvas");p.width=i*n,p.height=t*n;const s=k(p);if(!s){this._webglAvailable=!1;return}try{const d=D(s,o.vertexShader,o.fragmentShader);s.useProgram(d.program);const h=z(s,this._image),g=M(s,d);s.viewport(0,0,p.width,p.height),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,h.texture);const A=d.uniformLocations.get("u_image");A&&s.uniform1i(A,0),L(s,d,this._getUniformValues(h,n,f)),s.bindBuffer(s.ARRAY_BUFFER,g);const U=4*Float32Array.BYTES_PER_ELEMENT,y=d.attribLocations.get("a_position");y!==void 0&&y!==-1&&(s.enableVertexAttribArray(y),s.vertexAttribPointer(y,2,s.FLOAT,!1,U,0));const w=d.attribLocations.get("a_texCoord");w!==void 0&&w!==-1&&(s.enableVertexAttribArray(w),s.vertexAttribPointer(w,2,s.FLOAT,!1,U,2*Float32Array.BYTES_PER_ELEMENT)),P(s);const K=await new Promise($=>p.toBlob($));s.deleteTexture(h.texture),s.deleteProgram(d.program),s.deleteBuffer(g),K&&(this._snapshotLoaded=!1,this._revokeSnapshot(),this._snapshotUrl=URL.createObjectURL(K))}finally{(v=s.getExtension("WEBGL_lose_context"))==null||v.loseContext()}}_onSnapshotLoad(){this._snapshotLoaded=!0}replayTransition(o=500){this._snapshotUrl&&(this._snapshotLoaded=!1,this.updateComplete.then(()=>{setTimeout(()=>{this._snapshotLoaded=!0},o)}))}_revokeSnapshot(){this._snapshotUrl&&(URL.revokeObjectURL(this._snapshotUrl),this._snapshotUrl="")}_getUniformValues(o,n,i){const t={};return t.u_resolution=[o.width*n,o.height*n],t.u_dotRadius=this.dotRadius*i,t.u_gridSize=this.gridSize*i,this.effect==="halftone-cmyk"?(t.u_angleC=this.angleC,t.u_angleM=this.angleM,t.u_angleY=this.angleY,t.u_angleK=this.angleK,t.u_showC=this.showC,t.u_showM=this.showM,t.u_showY=this.showY,t.u_showK=this.showK,t.u_intensityK=this.intensityK):this.effect==="halftone-duotone"?(t.u_duotoneColor=this._parseHexColor(this.duotoneColor),t.u_angle=this.angle):this.effect==="dot-grid"?(t.u_dotOffset=[this.dotOffsetX,this.dotOffsetY],t.u_bgColor=this._parseHexColor(this.bgColor),t.u_angle=this.angle):this.effect==="technicolor-2strip"&&(t.u_angleWarm=this.angleWarm,t.u_angleCool=this.angleCool,t.u_angleK=this.angleK,t.u_showWarm=this.showWarm,t.u_showCool=this.showCool,t.u_showK=this.showK,t.u_warmColor=this._parseHexColor(this.warmColor),t.u_coolColor=this._parseHexColor(this.coolColor),t.u_blendMode=this.blendMode,t.u_intensityK=this.intensityK),t}_parseHexColor(o){const n=o.replace("#",""),i=parseInt(n.substring(0,2),16)/255,t=parseInt(n.substring(2,4),16)/255,a=parseInt(n.substring(4,6),16)/255;return[i,t,a]}};R.styles=m.css`
283
+ `:m.html`<img src=${this.src} alt="" />`}connectedCallback(){super.connectedCallback(),this._observer=new IntersectionObserver(o=>{var t;const a=this._visible;this._visible=((t=o[0])==null?void 0:t.isIntersecting)??!1,this._visible&&!a&&(this._needsRender||this._image&&!this._snapshotUrl)&&(this._needsRender=!1,R(()=>this._renderEffect()))},{rootMargin:"200px"}),this._observer.observe(this)}updated(o){if(o.has("src")&&this.src){this._loadImage(this.src);return}if(!this._image)return;[...o.keys()].some(t=>Y.has(t))&&this._scheduleRender()}disconnectedCallback(){var o;super.disconnectedCallback(),(o=this._observer)==null||o.disconnect(),this._revokeSnapshot()}_loadImage(o){const a=new Image;a.crossOrigin="anonymous",a.onload=()=>{this._image=a,this._scheduleRender()},a.onerror=()=>{console.warn(`[some-shade] Failed to load image: ${o}`)},a.src=o}_scheduleRender(){this._visible?R(()=>this._renderEffect()):(this._needsRender=!0,requestAnimationFrame(()=>{if(this._needsRender&&!this._visible){const o=this.getBoundingClientRect();o.bottom>=0&&o.top<window.innerHeight&&(this._visible=!0,this._needsRender=!1,R(()=>this._renderEffect()))}}))}async _renderEffect(){var v;if(!this._image)return;const o=x(this.effect);if(!o){console.warn(`[some-shade] Unknown effect: ${this.effect}`);return}const a=Math.min(window.devicePixelRatio||1,W),t=this._image.naturalWidth,u=this._image.naturalHeight,r=document.createElement("canvas");r.width=t*a,r.height=u*a;const n=U(r);if(!n){this._webglAvailable=!1;return}try{const c=K(n,o.vertexShader,o.fragmentShader);n.useProgram(c.program);const _=D(n,this._image),f=L(n,c);n.viewport(0,0,r.width,r.height),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.activeTexture(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,_.texture);const h=c.uniformLocations.get("u_image");h&&n.uniform1i(h,0),k(n,c,this._getUniformValues(_,a)),n.bindBuffer(n.ARRAY_BUFFER,f);const g=4*Float32Array.BYTES_PER_ELEMENT,y=c.attribLocations.get("a_position");y!==void 0&&y!==-1&&(n.enableVertexAttribArray(y),n.vertexAttribPointer(y,2,n.FLOAT,!1,g,0));const w=c.attribLocations.get("a_texCoord");w!==void 0&&w!==-1&&(n.enableVertexAttribArray(w),n.vertexAttribPointer(w,2,n.FLOAT,!1,g,2*Float32Array.BYTES_PER_ELEMENT)),M(n);const A=await new Promise(B=>r.toBlob(B));n.deleteTexture(_.texture),n.deleteProgram(c.program),n.deleteBuffer(f),A&&(this._snapshotLoaded=!1,this._revokeSnapshot(),this._snapshotUrl=URL.createObjectURL(A))}finally{(v=n.getExtension("WEBGL_lose_context"))==null||v.loseContext()}}_onSnapshotLoad(){this._snapshotLoaded=!0}replayTransition(o=500){this._snapshotUrl&&(this._snapshotLoaded=!1,this.updateComplete.then(()=>{setTimeout(()=>{this._snapshotLoaded=!0},o)}))}_revokeSnapshot(){this._snapshotUrl&&(URL.revokeObjectURL(this._snapshotUrl),this._snapshotUrl="")}_getUniformValues(o,a){const t={};t.u_resolution=[o.width*a,o.height*a];const u=o.width/this.referenceWidth;return t.u_dotRadius=this.dotRadius*u,t.u_gridSize=this.gridSize*u,this.effect==="halftone-cmyk"?(t.u_angleC=this.angleC,t.u_angleM=this.angleM,t.u_angleY=this.angleY,t.u_angleK=this.angleK,t.u_showC=this.showC,t.u_showM=this.showM,t.u_showY=this.showY,t.u_showK=this.showK,t.u_intensityK=this.intensityK):this.effect==="halftone-duotone"?(t.u_duotoneColor=this._parseHexColor(this.duotoneColor),t.u_angle=this.angle):this.effect==="dot-grid"?(t.u_dotOffset=[this.dotOffsetX,this.dotOffsetY],t.u_bgColor=this._parseHexColor(this.bgColor),t.u_angle=this.angle):this.effect==="technicolor-2strip"&&(t.u_angleWarm=this.angleWarm,t.u_angleCool=this.angleCool,t.u_angleK=this.angleK,t.u_showWarm=this.showWarm,t.u_showCool=this.showCool,t.u_showK=this.showK,t.u_warmColor=this._parseHexColor(this.warmColor),t.u_coolColor=this._parseHexColor(this.coolColor),t.u_blendMode=this.blendMode,t.u_intensityK=this.intensityK),t}_parseHexColor(o){const a=o.replace("#",""),t=parseInt(a.substring(0,2),16)/255,u=parseInt(a.substring(2,4),16)/255,r=parseInt(a.substring(4,6),16)/255;return[t,u,r]}};S.styles=m.css`
284
284
  :host {
285
285
  display: block;
286
286
  position: relative;
@@ -292,6 +292,9 @@ void main() {
292
292
  width: 100%;
293
293
  height: auto;
294
294
  }
295
+ img.base {
296
+ opacity: 0;
297
+ }
295
298
  img.snapshot {
296
299
  position: absolute;
297
300
  inset: 0;
@@ -303,4 +306,4 @@ void main() {
303
306
  img.snapshot.loaded {
304
307
  opacity: 1;
305
308
  }
306
- `;let r=R;u([l.property()],r.prototype,"src"),u([l.property()],r.prototype,"effect"),u([l.property({type:Number,attribute:"dot-radius"})],r.prototype,"dotRadius"),u([l.property({type:Number,attribute:"grid-size"})],r.prototype,"gridSize"),u([l.property({type:Number,attribute:"angle-c"})],r.prototype,"angleC"),u([l.property({type:Number,attribute:"angle-m"})],r.prototype,"angleM"),u([l.property({type:Number,attribute:"angle-y"})],r.prototype,"angleY"),u([l.property({type:Number,attribute:"angle-k"})],r.prototype,"angleK"),u([l.property({type:Number,attribute:"show-c"})],r.prototype,"showC"),u([l.property({type:Number,attribute:"show-m"})],r.prototype,"showM"),u([l.property({type:Number,attribute:"show-y"})],r.prototype,"showY"),u([l.property({type:Number,attribute:"show-k"})],r.prototype,"showK"),u([l.property({type:Number,attribute:"intensity-k"})],r.prototype,"intensityK"),u([l.property({attribute:"duotone-color"})],r.prototype,"duotoneColor"),u([l.property({type:Number})],r.prototype,"angle"),u([l.property({type:Number,attribute:"dot-offset-x"})],r.prototype,"dotOffsetX"),u([l.property({type:Number,attribute:"dot-offset-y"})],r.prototype,"dotOffsetY"),u([l.property({attribute:"bg-color"})],r.prototype,"bgColor"),u([l.property({type:Number,attribute:"angle-warm"})],r.prototype,"angleWarm"),u([l.property({type:Number,attribute:"angle-cool"})],r.prototype,"angleCool"),u([l.property({type:Number,attribute:"show-warm"})],r.prototype,"showWarm"),u([l.property({type:Number,attribute:"show-cool"})],r.prototype,"showCool"),u([l.property({attribute:"warm-color"})],r.prototype,"warmColor"),u([l.property({attribute:"cool-color"})],r.prototype,"coolColor"),u([l.property({type:Number,attribute:"blend-mode"})],r.prototype,"blendMode"),u([l.property({type:Number,attribute:"loading-blur"})],r.prototype,"loadingBlur"),u([l.state()],r.prototype,"_webglAvailable"),u([l.state()],r.prototype,"_snapshotUrl"),u([l.state()],r.prototype,"_snapshotLoaded"),customElements.get("some-shade-image")||customElements.define("some-shade-image",r),c.SomeShadeImage=r,c.get=x,c.list=F,c.register=_,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
309
+ `;let i=S;l([s.property()],i.prototype,"src"),l([s.property()],i.prototype,"effect"),l([s.property({type:Number,attribute:"dot-radius"})],i.prototype,"dotRadius"),l([s.property({type:Number,attribute:"grid-size"})],i.prototype,"gridSize"),l([s.property({type:Number,attribute:"angle-c"})],i.prototype,"angleC"),l([s.property({type:Number,attribute:"angle-m"})],i.prototype,"angleM"),l([s.property({type:Number,attribute:"angle-y"})],i.prototype,"angleY"),l([s.property({type:Number,attribute:"angle-k"})],i.prototype,"angleK"),l([s.property({type:Number,attribute:"show-c"})],i.prototype,"showC"),l([s.property({type:Number,attribute:"show-m"})],i.prototype,"showM"),l([s.property({type:Number,attribute:"show-y"})],i.prototype,"showY"),l([s.property({type:Number,attribute:"show-k"})],i.prototype,"showK"),l([s.property({type:Number,attribute:"intensity-k"})],i.prototype,"intensityK"),l([s.property({attribute:"duotone-color"})],i.prototype,"duotoneColor"),l([s.property({type:Number})],i.prototype,"angle"),l([s.property({type:Number,attribute:"dot-offset-x"})],i.prototype,"dotOffsetX"),l([s.property({type:Number,attribute:"dot-offset-y"})],i.prototype,"dotOffsetY"),l([s.property({attribute:"bg-color"})],i.prototype,"bgColor"),l([s.property({type:Number,attribute:"angle-warm"})],i.prototype,"angleWarm"),l([s.property({type:Number,attribute:"angle-cool"})],i.prototype,"angleCool"),l([s.property({type:Number,attribute:"show-warm"})],i.prototype,"showWarm"),l([s.property({type:Number,attribute:"show-cool"})],i.prototype,"showCool"),l([s.property({attribute:"warm-color"})],i.prototype,"warmColor"),l([s.property({attribute:"cool-color"})],i.prototype,"coolColor"),l([s.property({type:Number,attribute:"blend-mode"})],i.prototype,"blendMode"),l([s.property({type:Number,attribute:"reference-width"})],i.prototype,"referenceWidth"),l([s.state()],i.prototype,"_webglAvailable"),l([s.state()],i.prototype,"_snapshotUrl"),l([s.state()],i.prototype,"_snapshotLoaded"),customElements.get("some-shade-image")||customElements.define("some-shade-image",i),d.SomeShadeImage=i,d.get=x,d.list=N,d.register=p,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnfmorton/some-shade",
3
- "version": "1.0.1",
3
+ "version": "1.1.2",
4
4
  "license": "ISC",
5
5
  "homepage": "https://johnfmorton.github.io/some-shade-web-component/",
6
6
  "repository": {