@colordx/gpu 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/glsl.js +5 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colordx/gpu",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "colordx color math on the GPU — OKLCH/LCH conversions and gamut tests as generated GLSL, parity-tested against @colordx/core. Ships a WebGL2 gamut-slice chart renderer; shader chunks and WebGPU batch conversion on the roadmap",
5
5
  "author": "Dmitrii Kriaklin",
6
6
  "license": "MIT",
package/src/glsl.js CHANGED
@@ -77,12 +77,12 @@ float overflow(vec3 c) {
77
77
  vec3 d = max(c - 1.0, -c);
78
78
  return max(d.r, max(d.g, d.b));
79
79
  }
80
- // coverage of a u_borderWidth-px-wide band centered on the field's zero
81
- // contour: fwidth(field) is the field's change across one device pixel, so
82
- // dividing by it converts field distance to pixel distance
80
+ // crisp boundary line: distance to the field's zero contour in device
81
+ // pixels (length, not fwidth's |dx|+|dy|), solid within half the border
82
+ // width with no anti-aliased feather to pastel into the gamut fill
83
83
  float contour(float field) {
84
- float px = max(fwidth(field), 1e-12);
85
- return clamp((0.5 * u_borderWidth + 0.5) - abs(field) / px, 0.0, 1.0);
84
+ float px = max(length(vec2(dFdx(field), dFdy(field))), 1e-12);
85
+ return step(abs(field) / px, 0.5 * u_borderWidth);
86
86
  }
87
87
  // composite the border over the fill by its pixel coverage; alpha only
88
88
  // grows so a translucent border can't punch a hole in an opaque fill