palette-shader 0.18.0 → 0.19.0

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.
@@ -1750,7 +1750,7 @@ uniform sampler2D paletteTexture;
1750
1750
  return e && (o += `uniform vec2 uvOverride;
1751
1751
  `), o += F(a), o += P + st, o;
1752
1752
  }
1753
- const xt = `
1753
+ const Et = `
1754
1754
  precision highp float;
1755
1755
  layout(location = 0) in vec3 a_position;
1756
1756
  out vec3 vColorCoord;
@@ -1772,7 +1772,7 @@ void main() {
1772
1772
  vColorCoord = pos;
1773
1773
  #endif
1774
1774
  gl_Position = uMVP * vec4(pos - 0.5, 1.0);
1775
- }`, Et = `
1775
+ }`, xt = `
1776
1776
  precision highp float;
1777
1777
  layout(location = 0) in vec3 a_position;
1778
1778
  out vec3 vColorCoord;
@@ -1950,7 +1950,7 @@ void main() {
1950
1950
  return;
1951
1951
  }
1952
1952
  fragColor = center;
1953
- }`, w = { x: 0, y: 1, z: 2 }, Mt = 31, yt = 32, x = {
1953
+ }`, w = { x: 0, y: 1, z: 2 }, Mt = 31, yt = 32, E = {
1954
1954
  rgb: 0,
1955
1955
  rgb12bit: 1,
1956
1956
  rgb8bit: 2,
@@ -1984,7 +1984,7 @@ void main() {
1984
1984
  spectrum: 28,
1985
1985
  oklchDiag: 29,
1986
1986
  oklrchDiag: 30
1987
- }, E = {
1987
+ }, x = {
1988
1988
  rgb: 0,
1989
1989
  oklab: 1,
1990
1990
  deltaE76: 2,
@@ -2129,18 +2129,18 @@ class Xt extends lt {
2129
2129
  #s = null;
2130
2130
  #g = null;
2131
2131
  #C = null;
2132
- #M = null;
2133
2132
  #y = null;
2133
+ #O = null;
2134
2134
  // 1×1 float FBO for getColorAtUV_float (lazily created)
2135
2135
  #m = null;
2136
2136
  #p = null;
2137
2137
  #h = null;
2138
2138
  #I = null;
2139
2139
  #D = null;
2140
- #O = null;
2141
2140
  #S = null;
2141
+ #P = null;
2142
2142
  #w = null;
2143
- #P = !0;
2143
+ #A = !0;
2144
2144
  constructor({
2145
2145
  palette: t = J(),
2146
2146
  width: n = 512,
@@ -2167,13 +2167,13 @@ class Xt extends lt {
2167
2167
  canvasClassName: "palette-viz"
2168
2168
  }), this.#o = i, this.#c = l, this.#i = _, this.#d = b, this.#f = this.normalizeInvertAxes(C), this.#_ = f, this.#v = h, this.#n = d;
2169
2169
  const c = this.glContext;
2170
- this.#l = c.createBuffer(), c.bindBuffer(c.ARRAY_BUFFER, this.#l), c.bufferData(c.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), c.STATIC_DRAW), this.#a = c.createVertexArray(), c.bindVertexArray(this.#a), c.enableVertexAttribArray(0), c.vertexAttribPointer(0, 2, c.FLOAT, !1, 0, 0), c.bindVertexArray(null), this.#x(), this.syncCanvasSize(this.width, this.height), this.#E(), this.attachCanvas(), this.schedulePaint();
2170
+ this.#l = c.createBuffer(), c.bindBuffer(c.ARRAY_BUFFER, this.#l), c.bufferData(c.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), c.STATIC_DRAW), this.#a = c.createVertexArray(), c.bindVertexArray(this.#a), c.enableVertexAttribArray(0), c.vertexAttribPointer(0, 2, c.FLOAT, !1, 0, 0), c.bindVertexArray(null), this.#E(), this.syncCanvasSize(this.width, this.height), this.#x(), this.attachCanvas(), this.schedulePaint();
2171
2171
  }
2172
2172
  #k() {
2173
2173
  const t = this.#o.endsWith("Polar") && this.#f.includes("y");
2174
2174
  return {
2175
- DISTANCE_METRIC: E[this.#c],
2176
- COLOR_MODEL: x[this.#o],
2175
+ DISTANCE_METRIC: x[this.#c],
2176
+ COLOR_MODEL: E[this.#o],
2177
2177
  PROGRESS_AXIS: w[this.#i],
2178
2178
  INVERT_X: this.#f.includes("x") ? 1 : !1,
2179
2179
  INVERT_Y: this.#f.includes("y") && !t ? 1 : !1,
@@ -2183,19 +2183,19 @@ class Xt extends lt {
2183
2183
  GAMUT_CLIP: this.#n ? 1 : !1
2184
2184
  };
2185
2185
  }
2186
- #x() {
2186
+ #E() {
2187
2187
  const t = this.glContext;
2188
2188
  this.#t && t.deleteProgram(this.#t);
2189
2189
  const n = V(
2190
- x[this.#o],
2191
- E[this.#c],
2190
+ E[this.#o],
2191
+ x[this.#c],
2192
2192
  this.#_
2193
2193
  );
2194
- this.#t = y(t, this.#k(), n, S), this.#u = t.getUniformLocation(this.#t, "progress"), this.#T = t.getUniformLocation(this.#t, "paletteTexture"), this.#b = t.getUniformLocation(this.#t, "paletteMetricTexture"), this.#R = t.getUniformLocation(this.#t, "uPaletteSize"), this.metricPaletteDirty = !0, this.#P = !0;
2194
+ this.#t = y(t, this.#k(), n, S), this.#u = t.getUniformLocation(this.#t, "progress"), this.#T = t.getUniformLocation(this.#t, "paletteTexture"), this.#b = t.getUniformLocation(this.#t, "paletteMetricTexture"), this.#R = t.getUniformLocation(this.#t, "uPaletteSize"), this.metricPaletteDirty = !0, this.#A = !0;
2195
2195
  }
2196
- #E() {
2196
+ #x() {
2197
2197
  const t = this.glContext;
2198
- this.#g = y(t, {}, it, S), this.#C = t.getUniformLocation(this.#g, "colorMap"), this.#M = t.getUniformLocation(this.#g, "outlineWidth"), this.#y = t.getUniformLocation(this.#g, "resolution"), this.#s = t.createTexture(), this.#e = t.createFramebuffer(), this.#L(this.canvas.width, this.canvas.height);
2198
+ this.#g = y(t, {}, it, S), this.#C = t.getUniformLocation(this.#g, "colorMap"), this.#y = t.getUniformLocation(this.#g, "outlineWidth"), this.#O = t.getUniformLocation(this.#g, "resolution"), this.#s = t.createTexture(), this.#e = t.createFramebuffer(), this.#L(this.canvas.width, this.canvas.height);
2199
2199
  }
2200
2200
  #L(t, n) {
2201
2201
  const e = this.glContext;
@@ -2208,15 +2208,15 @@ class Xt extends lt {
2208
2208
  ), e.bindFramebuffer(e.FRAMEBUFFER, null);
2209
2209
  }
2210
2210
  currentMetricCode() {
2211
- return E[this.#c];
2211
+ return x[this.#c];
2212
2212
  }
2213
2213
  onSurfaceResized(t, n) {
2214
2214
  this.#s && this.#L(t, n);
2215
2215
  }
2216
2216
  renderFrame() {
2217
- this.#r && (this.#x(), this.#r = !1);
2217
+ this.#r && (this.#E(), this.#r = !1);
2218
2218
  const t = this.glContext;
2219
- t.bindFramebuffer(t.FRAMEBUFFER, this.#e), t.useProgram(this.#t), this.uploadMetricPalette(this.#R), t.uniform1f(this.#u, this.#d), t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, this.paletteTexture), t.uniform1i(this.#T, 0), t.activeTexture(t.TEXTURE1), t.bindTexture(t.TEXTURE_2D, this.metricTexture), t.uniform1i(this.#b, 1), t.clearColor(0, 0, 0, 0), t.clear(t.COLOR_BUFFER_BIT), t.bindVertexArray(this.#a), t.drawArrays(t.TRIANGLE_STRIP, 0, 4), t.flush(), t.bindFramebuffer(t.FRAMEBUFFER, null), t.useProgram(this.#g), t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, this.#s), t.uniform1i(this.#C, 0), t.uniform1f(this.#M, this.#_ ? 0 : this.#v), t.uniform2f(this.#y, this.canvas.width, this.canvas.height), t.clearColor(0, 0, 0, 0), t.clear(t.COLOR_BUFFER_BIT), t.drawArrays(t.TRIANGLE_STRIP, 0, 4), t.bindVertexArray(null);
2219
+ t.bindFramebuffer(t.FRAMEBUFFER, this.#e), t.useProgram(this.#t), this.uploadMetricPalette(this.#R), t.uniform1f(this.#u, this.#d), t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, this.paletteTexture), t.uniform1i(this.#T, 0), t.activeTexture(t.TEXTURE1), t.bindTexture(t.TEXTURE_2D, this.metricTexture), t.uniform1i(this.#b, 1), t.clearColor(0, 0, 0, 0), t.clear(t.COLOR_BUFFER_BIT), t.bindVertexArray(this.#a), t.drawArrays(t.TRIANGLE_STRIP, 0, 4), t.bindFramebuffer(t.FRAMEBUFFER, null), t.useProgram(this.#g), t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, this.#s), t.uniform1i(this.#C, 0), t.uniform1f(this.#y, this.#_ ? 0 : this.#v), t.uniform2f(this.#O, this.canvas.width, this.canvas.height), t.clearColor(0, 0, 0, 0), t.clear(t.COLOR_BUFFER_BIT), t.drawArrays(t.TRIANGLE_STRIP, 0, 4), t.bindVertexArray(null);
2220
2220
  }
2221
2221
  // ── Public API ──────────────────────────────────────────────────────────────
2222
2222
  destroy() {
@@ -2247,7 +2247,7 @@ class Xt extends lt {
2247
2247
  if (!Number.isFinite(t) || !Number.isFinite(n))
2248
2248
  throw new Error("x and y must be finite numbers");
2249
2249
  if (t < 0 || t > 1 || n < 0 || n > 1) throw new Error("x and y must be in the range [0, 1]");
2250
- this.flushScheduledPaint(), this.renderFrame();
2250
+ this.animationFrameId !== null && (this.flushScheduledPaint(), this.renderFrame());
2251
2251
  const e = this.glContext, a = Math.min(
2252
2252
  this.canvas.width - 1,
2253
2253
  Math.max(0, Math.round(t * (this.canvas.width - 1)))
@@ -2255,7 +2255,7 @@ class Xt extends lt {
2255
2255
  this.canvas.height - 1,
2256
2256
  Math.max(0, Math.round(n * (this.canvas.height - 1)))
2257
2257
  );
2258
- e.bindFramebuffer(e.FRAMEBUFFER, this.#e);
2258
+ e.bindFramebuffer(e.FRAMEBUFFER, this.#e), e.flush();
2259
2259
  const s = new Uint8Array(4);
2260
2260
  return e.readPixels(a, o, 1, 1, e.RGBA, e.UNSIGNED_BYTE, s), e.bindFramebuffer(e.FRAMEBUFFER, null), [s[0] / 255, s[1] / 255, s[2] / 255];
2261
2261
  }
@@ -2265,27 +2265,27 @@ class Xt extends lt {
2265
2265
  if (t < 0 || t > 1 || n < 0 || n > 1) throw new Error("x and y must be in the range [0, 1]");
2266
2266
  this.flushScheduledPaint();
2267
2267
  const e = this.glContext;
2268
- if (this.#m || (this.#p = e.createTexture(), e.bindTexture(e.TEXTURE_2D, this.#p), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA16F, 1, 1, 0, e.RGBA, e.HALF_FLOAT, null), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.NEAREST), e.bindTexture(e.TEXTURE_2D, null), this.#m = e.createFramebuffer(), e.bindFramebuffer(e.FRAMEBUFFER, this.#m), e.framebufferTexture2D(
2268
+ if (this.#m || (e.getExtension("EXT_color_buffer_float"), this.#p = e.createTexture(), e.bindTexture(e.TEXTURE_2D, this.#p), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA16F, 1, 1, 0, e.RGBA, e.HALF_FLOAT, null), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.NEAREST), e.bindTexture(e.TEXTURE_2D, null), this.#m = e.createFramebuffer(), e.bindFramebuffer(e.FRAMEBUFFER, this.#m), e.framebufferTexture2D(
2269
2269
  e.FRAMEBUFFER,
2270
2270
  e.COLOR_ATTACHMENT0,
2271
2271
  e.TEXTURE_2D,
2272
2272
  this.#p,
2273
2273
  0
2274
- ), e.bindFramebuffer(e.FRAMEBUFFER, null)), this.#P) {
2274
+ ), e.bindFramebuffer(e.FRAMEBUFFER, null)), this.#r && (this.#A = !0), this.#A) {
2275
2275
  this.#h && e.deleteProgram(this.#h);
2276
2276
  const s = { ...this.#k(), OUTPUT_LINEAR: 1 }, i = V(
2277
- x[this.#o],
2278
- E[this.#c],
2277
+ E[this.#o],
2278
+ x[this.#c],
2279
2279
  this.#_,
2280
2280
  !0
2281
2281
  );
2282
- this.#h = y(e, s, i, S), this.#I = e.getUniformLocation(this.#h, "progress"), this.#D = e.getUniformLocation(this.#h, "paletteTexture"), this.#O = e.getUniformLocation(
2282
+ this.#h = y(e, s, i, S), this.#I = e.getUniformLocation(this.#h, "progress"), this.#D = e.getUniformLocation(this.#h, "paletteTexture"), this.#S = e.getUniformLocation(
2283
2283
  this.#h,
2284
2284
  "paletteMetricTexture"
2285
- ), this.#S = e.getUniformLocation(this.#h, "uPaletteSize"), this.#w = e.getUniformLocation(this.#h, "uvOverride"), this.#P = !1;
2285
+ ), this.#P = e.getUniformLocation(this.#h, "uPaletteSize"), this.#w = e.getUniformLocation(this.#h, "uvOverride"), this.#A = !1;
2286
2286
  }
2287
2287
  const a = e.getParameter(e.VIEWPORT);
2288
- e.bindFramebuffer(e.FRAMEBUFFER, this.#m), e.viewport(0, 0, 1, 1), e.useProgram(this.#h), e.uniform2f(this.#w, t, n), e.uniform1f(this.#I, this.#d), this.uploadMetricPalette(this.#S), e.activeTexture(e.TEXTURE0), e.bindTexture(e.TEXTURE_2D, this.paletteTexture), e.uniform1i(this.#D, 0), e.activeTexture(e.TEXTURE1), e.bindTexture(e.TEXTURE_2D, this.metricTexture), e.uniform1i(this.#O, 1), e.clearColor(0, 0, 0, 0), e.clear(e.COLOR_BUFFER_BIT), e.bindVertexArray(this.#a), e.drawArrays(e.TRIANGLE_STRIP, 0, 4), e.flush();
2288
+ e.bindFramebuffer(e.FRAMEBUFFER, this.#m), e.viewport(0, 0, 1, 1), e.useProgram(this.#h), e.uniform2f(this.#w, t, n), e.uniform1f(this.#I, this.#d), e.uniform1i(this.#P, this.paletteState.length), e.activeTexture(e.TEXTURE0), e.bindTexture(e.TEXTURE_2D, this.paletteTexture), e.uniform1i(this.#D, 0), e.activeTexture(e.TEXTURE1), e.bindTexture(e.TEXTURE_2D, this.metricTexture), e.uniform1i(this.#S, 1), e.clearColor(0, 0, 0, 0), e.clear(e.COLOR_BUFFER_BIT), e.bindVertexArray(this.#a), e.drawArrays(e.TRIANGLE_STRIP, 0, 4), e.flush();
2289
2289
  const o = new Float32Array(4);
2290
2290
  return e.readPixels(0, 0, 1, 1, e.RGBA, e.FLOAT, o), e.bindFramebuffer(e.FRAMEBUFFER, null), e.bindVertexArray(null), e.viewport(a[0], a[1], a[2], a[3]), [o[0], o[1], o[2]];
2291
2291
  }
@@ -2304,14 +2304,14 @@ class Xt extends lt {
2304
2304
  return this.#i;
2305
2305
  }
2306
2306
  set colorModel(t) {
2307
- if (!(t in x)) throw new Error(`colorModel '${t}' is not supported`);
2307
+ if (!(t in E)) throw new Error(`colorModel '${t}' is not supported`);
2308
2308
  this.#o = t, this.#r = !0, this.schedulePaint();
2309
2309
  }
2310
2310
  get colorModel() {
2311
2311
  return this.#o;
2312
2312
  }
2313
2313
  set distanceMetric(t) {
2314
- if (!(t in E))
2314
+ if (!(t in x))
2315
2315
  throw new Error(`distanceMetric '${t}' is not supported`);
2316
2316
  this.#c = t, this.#r = !0, this.schedulePaint();
2317
2317
  }
@@ -2546,22 +2546,22 @@ class Ht extends lt {
2546
2546
  #s = 0;
2547
2547
  #g = 0;
2548
2548
  #C = null;
2549
- #M = null;
2550
2549
  #y = null;
2550
+ #O = null;
2551
2551
  #m = null;
2552
2552
  #p = null;
2553
2553
  #h = null;
2554
2554
  #I = null;
2555
2555
  #D = null;
2556
- #O = null;
2557
2556
  #S = null;
2558
- #w = null;
2559
2557
  #P = null;
2558
+ #w = null;
2559
+ #A = null;
2560
2560
  #k = new Float32Array(9);
2561
- #x = null;
2562
2561
  #E = null;
2562
+ #x = null;
2563
2563
  #L = null;
2564
- #A = null;
2564
+ #M = null;
2565
2565
  #F = null;
2566
2566
  #B = null;
2567
2567
  #X = null;
@@ -2591,7 +2591,7 @@ class Ht extends lt {
2591
2591
  observeResize: o,
2592
2592
  container: s,
2593
2593
  canvasClassName: "palette-viz-3d"
2594
- }), this.#o = i, this.#c = l, this.#f = this.normalizeInvertAxes(_), this.#_ = b, this.#v = C, this.#n = f, this.#d = h, this.#e = W.has(x[this.#o]), d ? this.#i = new Float32Array(d) : this.#i = new Float32Array(p(M(0.45), A(0.65))), this.#W(), this.#j(), this.syncCanvasSize(this.width, this.height), this.#N(), this.glContext.enable(this.glContext.DEPTH_TEST), this.#Q(), this.attachCanvas(), this.schedulePaint();
2594
+ }), this.#o = i, this.#c = l, this.#f = this.normalizeInvertAxes(_), this.#_ = b, this.#v = C, this.#n = f, this.#d = h, this.#e = W.has(E[this.#o]), d ? this.#i = new Float32Array(d) : this.#i = new Float32Array(p(M(0.45), A(0.65))), this.#W(), this.#j(), this.syncCanvasSize(this.width, this.height), this.#N(), this.glContext.enable(this.glContext.DEPTH_TEST), this.#Q(), this.attachCanvas(), this.schedulePaint();
2595
2595
  }
2596
2596
  #W() {
2597
2597
  const t = this.glContext;
@@ -2641,10 +2641,10 @@ class Ht extends lt {
2641
2641
  s.bindVertexArray(null);
2642
2642
  }
2643
2643
  #J() {
2644
- const t = x[this.#o];
2644
+ const t = E[this.#o];
2645
2645
  return {
2646
2646
  COLOR_MODEL: t,
2647
- DISTANCE_METRIC: E[this.#c],
2647
+ DISTANCE_METRIC: x[this.#c],
2648
2648
  INVERT_X: this.#f.includes("x") ? 1 : !1,
2649
2649
  INVERT_Y: this.#f.includes("y") ? 1 : !1,
2650
2650
  INVERT_Z: this.#f.includes("z") ? 1 : !1,
@@ -2660,14 +2660,14 @@ class Ht extends lt {
2660
2660
  const t = this.glContext;
2661
2661
  this.#t && t.deleteProgram(this.#t), this.#l && t.deleteProgram(this.#l);
2662
2662
  const n = Lt(
2663
- x[this.#o],
2664
- E[this.#c],
2663
+ E[this.#o],
2664
+ x[this.#c],
2665
2665
  this.#_
2666
2666
  ), e = At(
2667
- x[this.#o],
2667
+ E[this.#o],
2668
2668
  this.#n
2669
- ), a = this.#e ? Et : xt;
2670
- this.#t = y(t, this.#J(), n, a), this.#l = y(t, this.#J(), e, a), this.#M = t.getUniformLocation(this.#t, "uMVP"), this.#y = t.getUniformLocation(this.#l, "uMVP"), this.#m = t.getUniformLocation(this.#t, "uPosition"), this.#p = t.getUniformLocation(this.#l, "uPosition"), this.#h = t.getUniformLocation(this.#t, "paletteTexture"), this.#I = t.getUniformLocation(this.#t, "paletteMetricTexture"), this.#D = t.getUniformLocation(this.#t, "uPaletteSize"), this.#O = t.getUniformLocation(this.#t, "uColorRotation"), this.#S = t.getUniformLocation(this.#l, "uColorRotation"), this.#w = t.getUniformLocation(this.#t, "uSliceOffset"), this.#P = t.getUniformLocation(this.#l, "uSliceOffset"), this.metricPaletteDirty = !0;
2669
+ ), a = this.#e ? xt : Et;
2670
+ this.#t = y(t, this.#J(), n, a), this.#l = y(t, this.#J(), e, a), this.#y = t.getUniformLocation(this.#t, "uMVP"), this.#O = t.getUniformLocation(this.#l, "uMVP"), this.#m = t.getUniformLocation(this.#t, "uPosition"), this.#p = t.getUniformLocation(this.#l, "uPosition"), this.#h = t.getUniformLocation(this.#t, "paletteTexture"), this.#I = t.getUniformLocation(this.#t, "paletteMetricTexture"), this.#D = t.getUniformLocation(this.#t, "uPaletteSize"), this.#S = t.getUniformLocation(this.#t, "uColorRotation"), this.#P = t.getUniformLocation(this.#l, "uColorRotation"), this.#w = t.getUniformLocation(this.#t, "uSliceOffset"), this.#A = t.getUniformLocation(this.#l, "uSliceOffset"), this.metricPaletteDirty = !0;
2671
2671
  }
2672
2672
  #G(t, n, e, a) {
2673
2673
  const o = this.glContext;
@@ -2678,15 +2678,15 @@ class Ht extends lt {
2678
2678
  }
2679
2679
  #Q() {
2680
2680
  const t = this.glContext;
2681
- this.#E = t.createTexture(), this.#L = t.createRenderbuffer(), this.#x = t.createFramebuffer(), this.#K(this.canvas.width, this.canvas.height), this.#B = t.createBuffer(), t.bindBuffer(t.ARRAY_BUFFER, this.#B), t.bufferData(t.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), t.STATIC_DRAW), this.#F = t.createVertexArray(), t.bindVertexArray(this.#F), t.enableVertexAttribArray(0), t.vertexAttribPointer(0, 2, t.FLOAT, !1, 0, 0), t.bindVertexArray(null), this.#A = y(t, {}, it, S), this.#X = t.getUniformLocation(this.#A, "colorMap"), this.#H = t.getUniformLocation(this.#A, "outlineWidth"), this.#V = t.getUniformLocation(this.#A, "resolution");
2681
+ this.#x = t.createTexture(), this.#L = t.createRenderbuffer(), this.#E = t.createFramebuffer(), this.#K(this.canvas.width, this.canvas.height), this.#B = t.createBuffer(), t.bindBuffer(t.ARRAY_BUFFER, this.#B), t.bufferData(t.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), t.STATIC_DRAW), this.#F = t.createVertexArray(), t.bindVertexArray(this.#F), t.enableVertexAttribArray(0), t.vertexAttribPointer(0, 2, t.FLOAT, !1, 0, 0), t.bindVertexArray(null), this.#M = y(t, {}, it, S), this.#X = t.getUniformLocation(this.#M, "colorMap"), this.#H = t.getUniformLocation(this.#M, "outlineWidth"), this.#V = t.getUniformLocation(this.#M, "resolution");
2682
2682
  }
2683
2683
  #K(t, n) {
2684
2684
  const e = this.glContext;
2685
- e.bindTexture(e.TEXTURE_2D, this.#E), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA8, t, n, 0, e.RGBA, e.UNSIGNED_BYTE, null), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.NEAREST), 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.bindTexture(e.TEXTURE_2D, null), e.bindRenderbuffer(e.RENDERBUFFER, this.#L), e.renderbufferStorage(e.RENDERBUFFER, e.DEPTH_COMPONENT16, t, n), e.bindRenderbuffer(e.RENDERBUFFER, null), e.bindFramebuffer(e.FRAMEBUFFER, this.#x), e.framebufferTexture2D(
2685
+ e.bindTexture(e.TEXTURE_2D, this.#x), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA8, t, n, 0, e.RGBA, e.UNSIGNED_BYTE, null), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.NEAREST), 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.bindTexture(e.TEXTURE_2D, null), e.bindRenderbuffer(e.RENDERBUFFER, this.#L), e.renderbufferStorage(e.RENDERBUFFER, e.DEPTH_COMPONENT16, t, n), e.bindRenderbuffer(e.RENDERBUFFER, null), e.bindFramebuffer(e.FRAMEBUFFER, this.#E), e.framebufferTexture2D(
2686
2686
  e.FRAMEBUFFER,
2687
2687
  e.COLOR_ATTACHMENT0,
2688
2688
  e.TEXTURE_2D,
2689
- this.#E,
2689
+ this.#x,
2690
2690
  0
2691
2691
  ), e.framebufferRenderbuffer(
2692
2692
  e.FRAMEBUFFER,
@@ -2705,38 +2705,38 @@ class Ht extends lt {
2705
2705
  return p(n, p(e, this.#i));
2706
2706
  }
2707
2707
  currentMetricCode() {
2708
- return E[this.#c];
2708
+ return x[this.#c];
2709
2709
  }
2710
2710
  onSurfaceResized(t, n) {
2711
- this.#N(), this.#E && this.#K(t, n);
2711
+ this.#N(), this.#x && this.#K(t, n);
2712
2712
  }
2713
2713
  renderFrame() {
2714
- this.#N(), this.#R && (this.#e = W.has(x[this.#o]), this.#W(), this.#R = !1), this.#b && (this.#j(), this.#b = !1);
2714
+ this.#N(), this.#R && (this.#e = W.has(E[this.#o]), this.#W(), this.#R = !1), this.#b && (this.#j(), this.#b = !1);
2715
2715
  const t = this.glContext;
2716
- t.bindFramebuffer(t.FRAMEBUFFER, this.#x), t.clearColor(0, 0, 0, 0), t.clear(t.COLOR_BUFFER_BIT | t.DEPTH_BUFFER_BIT), (this.#n || this.#e) && (t.colorMask(!1, !1, !1, !1), this.#n ? this.#Y(
2716
+ t.bindFramebuffer(t.FRAMEBUFFER, this.#E), t.clearColor(0, 0, 0, 0), t.clear(t.COLOR_BUFFER_BIT | t.DEPTH_BUFFER_BIT), (this.#n || this.#e) && (t.colorMask(!1, !1, !1, !1), this.#n ? this.#Y(
2717
2717
  this.#l,
2718
- this.#y,
2718
+ this.#O,
2719
2719
  this.#p,
2720
- this.#S,
2721
- this.#P
2720
+ this.#P,
2721
+ this.#A
2722
2722
  ) : (this.#G(
2723
2723
  this.#l,
2724
- this.#y,
2724
+ this.#O,
2725
2725
  this.#p,
2726
- this.#S
2727
- ), t.bindVertexArray(this.#a), t.drawElements(t.TRIANGLES, this.#T, t.UNSIGNED_INT, 0), t.bindVertexArray(null)), t.colorMask(!0, !0, !0, !0), t.clear(t.COLOR_BUFFER_BIT), t.depthFunc(t.EQUAL), t.depthMask(!1)), this.#n ? t.useProgram(this.#t) : this.#G(this.#t, this.#M, this.#m, this.#O), this.uploadMetricPalette(this.#D), t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, this.paletteTexture), t.uniform1i(this.#h, 0), t.activeTexture(t.TEXTURE1), t.bindTexture(t.TEXTURE_2D, this.metricTexture), t.uniform1i(this.#I, 1), this.#n ? this.#Y(
2726
+ this.#P
2727
+ ), t.bindVertexArray(this.#a), t.drawElements(t.TRIANGLES, this.#T, t.UNSIGNED_INT, 0), t.bindVertexArray(null)), t.colorMask(!0, !0, !0, !0), t.clear(t.COLOR_BUFFER_BIT), t.depthFunc(t.EQUAL), t.depthMask(!1)), this.#n ? t.useProgram(this.#t) : this.#G(this.#t, this.#y, this.#m, this.#S), this.uploadMetricPalette(this.#D), t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, this.paletteTexture), t.uniform1i(this.#h, 0), t.activeTexture(t.TEXTURE1), t.bindTexture(t.TEXTURE_2D, this.metricTexture), t.uniform1i(this.#I, 1), this.#n ? this.#Y(
2728
2728
  this.#t,
2729
- this.#M,
2729
+ this.#y,
2730
2730
  this.#m,
2731
- this.#O,
2731
+ this.#S,
2732
2732
  this.#w
2733
- ) : (t.bindVertexArray(this.#a), t.drawElements(t.TRIANGLES, this.#T, t.UNSIGNED_INT, 0), t.bindVertexArray(null)), (this.#n || this.#e) && (t.depthMask(!0), t.depthFunc(t.LESS)), t.bindFramebuffer(t.FRAMEBUFFER, null), t.disable(t.DEPTH_TEST), t.useProgram(this.#A), t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, this.#E), t.uniform1i(this.#X, 0), t.uniform1f(this.#H, this.#_ ? 0 : this.#v), t.uniform2f(this.#V, this.canvas.width, this.canvas.height), t.clearColor(0, 0, 0, 0), t.clear(t.COLOR_BUFFER_BIT), t.bindVertexArray(this.#F), t.drawArrays(t.TRIANGLE_STRIP, 0, 4), t.bindVertexArray(null), t.enable(t.DEPTH_TEST);
2733
+ ) : (t.bindVertexArray(this.#a), t.drawElements(t.TRIANGLES, this.#T, t.UNSIGNED_INT, 0), t.bindVertexArray(null)), (this.#n || this.#e) && (t.depthMask(!0), t.depthFunc(t.LESS)), t.bindFramebuffer(t.FRAMEBUFFER, null), t.disable(t.DEPTH_TEST), t.useProgram(this.#M), t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, this.#x), t.uniform1i(this.#X, 0), t.uniform1f(this.#H, this.#_ ? 0 : this.#v), t.uniform2f(this.#V, this.canvas.width, this.canvas.height), t.clearColor(0, 0, 0, 0), t.clear(t.COLOR_BUFFER_BIT), t.bindVertexArray(this.#F), t.drawArrays(t.TRIANGLE_STRIP, 0, 4), t.bindVertexArray(null), t.enable(t.DEPTH_TEST);
2734
2734
  }
2735
2735
  getColorAtUV(t, n) {
2736
2736
  if (!Number.isFinite(t) || !Number.isFinite(n))
2737
2737
  throw new Error("x and y must be finite numbers");
2738
2738
  if (t < 0 || t > 1 || n < 0 || n > 1) throw new Error("x and y must be in the range [0, 1]");
2739
- this.flushScheduledPaint(), this.renderFrame();
2739
+ this.animationFrameId !== null && (this.flushScheduledPaint(), this.renderFrame());
2740
2740
  const e = this.glContext, a = Math.min(
2741
2741
  this.canvas.width - 1,
2742
2742
  Math.max(0, Math.round(t * (this.canvas.width - 1)))
@@ -2744,7 +2744,7 @@ class Ht extends lt {
2744
2744
  this.canvas.height - 1,
2745
2745
  Math.max(0, Math.round((1 - n) * (this.canvas.height - 1)))
2746
2746
  );
2747
- e.bindFramebuffer(e.FRAMEBUFFER, this.#x);
2747
+ e.bindFramebuffer(e.FRAMEBUFFER, this.#E);
2748
2748
  const s = new Uint8Array(4);
2749
2749
  return e.readPixels(a, o, 1, 1, e.RGBA, e.UNSIGNED_BYTE, s), e.bindFramebuffer(e.FRAMEBUFFER, null), s[3] === 0 ? null : [s[0] / 255, s[1] / 255, s[2] / 255];
2750
2750
  }
@@ -2755,17 +2755,17 @@ class Ht extends lt {
2755
2755
  if (!this.beginDestroy()) return;
2756
2756
  this.#C !== null && (window.clearTimeout(this.#C), this.#C = null);
2757
2757
  const t = this.glContext;
2758
- this.#A && t.deleteProgram(this.#A), this.#l && t.deleteProgram(this.#l), this.#F && t.deleteVertexArray(this.#F), this.#B && t.deleteBuffer(this.#B), this.#E && t.deleteTexture(this.#E), this.#L && t.deleteRenderbuffer(this.#L), this.#x && t.deleteFramebuffer(this.#x), this.#t && t.deleteProgram(this.#t), this.#r && t.deleteBuffer(this.#r), this.#u && t.deleteBuffer(this.#u), this.#a && t.deleteVertexArray(this.#a), this.destroyBaseResources();
2758
+ this.#M && t.deleteProgram(this.#M), this.#l && t.deleteProgram(this.#l), this.#F && t.deleteVertexArray(this.#F), this.#B && t.deleteBuffer(this.#B), this.#x && t.deleteTexture(this.#x), this.#L && t.deleteRenderbuffer(this.#L), this.#E && t.deleteFramebuffer(this.#E), this.#t && t.deleteProgram(this.#t), this.#r && t.deleteBuffer(this.#r), this.#u && t.deleteBuffer(this.#u), this.#a && t.deleteVertexArray(this.#a), this.destroyBaseResources();
2759
2759
  }
2760
2760
  set colorModel(t) {
2761
- if (!(t in x)) throw new Error(`colorModel '${t}' is not supported`);
2761
+ if (!(t in E)) throw new Error(`colorModel '${t}' is not supported`);
2762
2762
  this.#o = t, this.#b = !0, this.#R = !0, this.schedulePaint();
2763
2763
  }
2764
2764
  get colorModel() {
2765
2765
  return this.#o;
2766
2766
  }
2767
2767
  set distanceMetric(t) {
2768
- if (!(t in E))
2768
+ if (!(t in x))
2769
2769
  throw new Error(`distanceMetric '${t}' is not supported`);
2770
2770
  this.#c = t, this.#b = !0, this.schedulePaint();
2771
2771
  }