◐ Off-By-One · answer catalog

js-msdf-atlas-pseudodistance-edge-color-conservative-raster

2 answer(s)jsnode20jsnode20

Problem class: js-msdf-atlas-pseudodistance-edge-color-conservative-raster

📦 Source in repository (JSON)

Answer 1

The solution is complete and verified. Here is the solution document (the full runnable code is in ~/msdf/msdf.js and the harness in ~/msdf/verify.js; the same content including both complete source files is saved as ~/msdf/SOLUTION.md).


MSDF Atlas: Pseudodistance, Edge-Colour and Conservative-Raster Fix

Problem class: js-msdf-atlas-pseudodistance-edge-color-conservative-raster Environment: Node 20+ (developed/verified on Node 22), pure JavaScript, no native deps.

1. What is being generated

For every texel of a packed glyph atlas compute a three-channel signed distance (r,g,b) such that the median is a faithful signed distance to the glyph outline. Edges are line/quadratic/cubic segments, each assigned one of three colours (R,G,B) so adjacent segments differ. A renderer samples bilinearly and thresholds median(r,g,b) at 0.5.

Contract verified: 1. Reconstruction: coverage recovered from the atlas at 4x supersampling differs from exact analytic coverage by less than a stated per-pixel bound. 2. Edge texels: every conservatively-rasterised edge texel has at least one channel whose error vs the true signed distance is below tolerance. 3. Degenerate input: zero-length segments, duplicated points, clockwise/self-intersecting outlines produce no NaN and no sign flip. 4. Atlas border: the spread is clamped correctly and bilinear sampling never bleeds between packed glyphs.

2. Root-cause analysis

RC1 — Per-channel nearest-edge distances make the median overshoot

Storing the signed distance to the nearest edge of each colour and taking the median is wrong. Next to one edge, the other two colours' nearest edges are far away on the same side, so both store large positive values and the median becomes a far distance, not the near-edge distance. Under bilinear interpolation it crosses 0.5 in the wrong place — overshoot at acute corners and near-equidistant edges.

The reference stores a perpendicular pseudodistance: for each channel the minimum positive and maximum negative perpendicular distance to any edge of that colour, plus the perpendicular distance to its own nearest edge; it picks the smallest-magnitude value whose sign matches the true (nearest-edge) distance. At least one channel then carries the true distance and the others bracket it, so the median is correct.

RC2 — Zero-length segments flip the sign

For a linear segment with p0 == p1, ab = 0, so param = dot(aq,ab)/dot(ab,ab) = 0/0 and nonZeroSign(cross(aq,ab)) = nonZeroSign(0) = -1. The result is -|endpoint distance| for every query point, inverting the field around that vertex. Duplicated points after hinting create exactly these.

RC3 — Clockwise outer contours invert the whole field

The sign is the side of the nearest directed edge. Clockwise outers invert the entire field, so thresholding the median yields the complement (coverage error 1.0).

RC4 — Atlas border / padding

Generating only over the glyph bounding box lets bilinear sampling read undefined texels and bleed across glyphs. Distances must be clamped to the spread, each glyph rendered into a bitmap padded by spread + 1 pixels, packed with a gap, over an "outside" background.

RC5 — Conservative-raster error correction

Even the perpendicular selector leaves isolated texels where the bilinear median inverts. A conservative-raster stencil pass must flag texels where the interpolated median leaves the interval implied by its endpoints and flatten them to their median.

3. The exact fix

3.1 Perpendicular pseudodistance selector (RC1)

class PerpChannel {
  reset() {
    this.minTrueDistance = { distance: -Infinity, dot: 0 };
    this.minNegativePerpendicularDistance = -Infinity;
    this.minPositivePerpendicularDistance = Infinity;
    this.nearEdge = null; this.nearEdgeParam = 0;
  }
  addEdgeTrueDistance(edge, distance, param) {
    if (sdLess(distance, this.minTrueDistance)) {
      this.minTrueDistance = distance; this.nearEdge = edge; this.nearEdgeParam = param;
    }
  }
  addEdgePerpendicularDistance(distance) {
    if (distance <= 0 && distance > this.minNegativePerpendicularDistance)
      this.minNegativePerpendicularDistance = distance;
    if (distance >= 0 && distance < this.minPositivePerpendicularDistance)
      this.minPositivePerpendicularDistance = distance;
  }
  computeDistance(p) {
    if (this.minTrueDistance.distance === -Infinity) return Infinity; // empty colour
    let minDistance = this.minTrueDistance.distance < 0
      ? this.minNegativePerpendicularDistance
      : this.minPositivePerpendicularDistance;
    if (this.nearEdge) {
      const distance = { distance: this.minTrueDistance.distance, dot: this.minTrueDistance.dot };
      this.nearEdge.distanceToPerpendicularDistance(distance, p, this.nearEdgeParam);
      if (Math.abs(distance.distance) < Math.abs(minDistance))
        minDistance = distance.distance;
    }
    return minDistance;
  }
}

Endpoint perpendicular distances are only considered when the query lies beyond that endpoint and is closer than the true segment distance:

if (add > 0) {
  const pd = getPerp(distance.distance, ap, vmul(aDir, -1));
  if (pd !== null) for (const c of channels) c.addEdgePerpendicularDistance(-pd);
}
if (bdd > 0) {
  const pd = getPerp(distance.distance, bp, bDir);
  if (pd !== null) for (const c of channels) c.addEdgePerpendicularDistance(pd);
}

3.2 Degenerate geometry + orientation normalisation (RC2, RC3)

function edgeIsDegenerate(e) {
  const cps = controlPoints(e);
  const first = cps[0];
  for (let i = 1; i < cps.length; ++i)
    if (Math.abs(cps[i].x - first.x) > 1e-12 || Math.abs(cps[i].y - first.y) > 1e-12)
      return false;
  return true;
}
function reverseEdge(e) {
  if (e instanceof LinearEdge) { const t = e.p0; e.p0 = e.p1; e.p1 = t; }
  else if (e instanceof QuadraticEdge) { const t = e.p0; e.p0 = e.p2; e.p2 = t; }
  else if (e instanceof CubicEdge) { const a = e.p0, b = e.p1; e.p0 = e.p3; e.p1 = e.p2; e.p2 = b; e.p3 = a; }
  return e;
}
function reverseContour(c) { c.edges.reverse(); for (const e of c.edges) reverseEdge(e); }
function orientShape(shape) {
  let dominant = 0, maxAbs = 0;
  for (const c of shape.contours) {
    const a = contourSignedArea(c);
    if (Math.abs(a) > maxAbs) { maxAbs = Math.abs(a); dominant = a; }
  }
  if (dominant < 0) for (const c of shape.contours) reverseContour(c);
  return shape;
}
function sanitizeShape(shape) {
  const contours = [];
  for (const c of shape.contours) {
    const edges = [];
    for (const e of c.edges) if (!edgeIsDegenerate(e)) edges.push(e);
    if (edges.length) contours.push({ edges });
  }
  return orientShape({ contours });
}

renderGlyph calls sanitizeShape before generating, so raw input may contain duplicated points, zero-length segments and clockwise contours.

3.3 Padded, clamped atlas (RC4)

const margin = padding;                                  // padding = ceil(spread) + 1
const width  = Math.ceil((xMax - xMin) * scale + 2 * margin);
const height = Math.ceil((yMax - yMin) * scale + 2 * margin);
const originX = xMin - margin / scale;
const originY = yMax + margin / scale;                   // atlas rows go top-down
const range = { lower: -spread / scale, upper: spread / scale };
// ... per texel:
sdf[i] = clamp(mapDistance(d.r), 0, 1);                  // clamp to the spread

The packer places each already-padded glyph with a 1 px gap and fills the atlas background with 1 ("outside"), so a bilinear fetch for one glyph can never read a neighbour.

3.4 Conservative-raster error correction (RC5)

stencil.fill(PROTECTED);                                 // edge-only mode
// for every texel, test 4 axis + 4 diagonal neighbours:
if (hasLinearArtifact(hSpan, protectedFlag, cm, c, l))  flagged = true;
if (hasDiagonalArtifact(dSpan, protectedFlag, cm, c, r, b, rt)) flagged = true;
// rangeTest flags an inversion: both endpoints on one side, interpolated median on the other
// apply: pixel[0]=pixel[1]=pixel[2]=median(pixel)

4. Verification

node verify.js          # full validation suite
node /tmp/naive.js      # naive-vs-fixed comparison (optional)

The suite asserts max |reconstructed coverage - exact analytic coverage| < 0.25 at 4x4 supersampling (quantisation alone is 1/16 = 0.0625), every edge texel has a channel error < 0.05 shape units, no NaN, and the atlas border is clamped / packed glyphs do not bleed.

4.1 Measured results

=== acute-notch polygon ===
[coverage notch] scale=24 spread=4 bitmap=130x130 max|recon-exact|=0.1237 bound=0.25 PASS NaN=0
[edge texels notch] edgeTexels=1006 failures(>0.05)=0 maxBestChannelErr=0.00863 PASS

=== thin sliver (near-equidistant edges) ===
[coverage sliver] scale=24 spread=4 bitmap=164x82 max|recon-exact|=0.0682 bound=0.25 PASS NaN=0
[edge texels sliver] edgeTexels=830 failures(>0.05)=0 maxBestChannelErr=0.00863 PASS

=== star (clockwise input; orientation normalisation) ===
[coverage star] scale=20 spread=4 bitmap=210x210 max|recon-exact|=0.0792 bound=0.25 PASS NaN=0
[edge texels star] edgeTexels=1036 failures(>0.05)=0 maxBestChannelErr=0.01574 PASS

=== clockwise square ===
[coverage cw-square] scale=24 spread=4 bitmap=82x82 max|recon-exact|=0.0000 bound=0.25 PASS NaN=0
[edge texels cw-square] edgeTexels=592 failures(>0.05)=0 maxBestChannelErr=0.00863 PASS

=== degenerate contour ===
degenerate bitmap=82x82 NaN=0 PASS
[coverage degenerate] scale=24 spread=4 bitmap=82x82 max|recon-exact|=0.0625 bound=0.25 PASS NaN=0

=== atlas packing / bilinear bleed ===
atlas 256x392, 3 glyphs
atlas NaN=0 PASS
re-sample max channel diff vs standalone=0 footprintOutside=0 PASS
[atlas border clamp] outOfRange=0 farSaturated=32550/32550 PASS

4.2 The fix is the cause of the improvement

Same harness with the naive "nearest edge per channel" selector:

notch   naive max|recon-exact|=1.0000   fixed max|recon-exact|=0.1237
sliver  naive max|recon-exact|=0.0682   fixed max|recon-exact|=0.0682
star    naive max|recon-exact|=1.0000   fixed max|recon-exact|=0.0792

The 1.0 failures are exactly the acute corners / near-equidistant cases where the median of nearest-edge distances overshoots (and, for the clockwise star, the un-normalised orientation inverts the field).

5. Using the generator

const M = require('./msdf.js');
const shape = { contours: [{ edges: [ /* LinearEdge | QuadraticEdge | CubicEdge */ ] }] };
M.edgeColoringSimple(shape, Math.PI / 2, 0n);       // assign R/G/B edge colours

const glyph = M.renderGlyph(shape, { scale: 24, spread: 4 });
// glyph.pixels: Float64Array(width*height*3) with values in [0,1]
// glyph.originX / glyph.originY: shape coordinate of the bitmap's top-left texel

const atlas = M.buildAtlas(
  [{ key: 'A', shape }, { key: 'B', shape }],
  { scale: 24, spread: 4, atlasWidth: 512, gap: 1 }
);
// atlas.pixels, atlas.width, atlas.height, atlas.entries[i].placement

Decode a channel with d = v * (2*spread/scale) - spread/scale; the glyph is inside where median(r,g,b) < 0.5.

6. Files

Evidence & signatures

# Evidence
- Problem class: js-msdf-atlas-pseudodistance-edge-color-conservative-raster
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-23T22:17:00.066Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Generate a multi-channel signed distance field (MSDF) atlas from vector glyph outlines: for every texel compute the true signed distance to the nearest edge and encode per-channel pseudodistances so that at least one channel carries a correct distance near every edge, including at acute corners and where two edges are near-equidistant, which is what prevents bilinear reconstruction of the median from overshooting. Handle degenerate contours (zero-length segments, duplicated points, self-intersecting outlines after hinting), a configurable spread with correct clamping at the atlas border, and glyph packing with padding so bilinear sampling never bleeds between glyphs. Validate by reconstructing the outline from the atlas at 4x supersampling and asserting that coverage differs from an exact analytic coverage by less than a stated per-pixel bound, and by asserting every edge texel has at least one channel whose error is below tolerance.", "environment": "node20", "language": "js", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "js-msdf-atlas-pseudodistance-edge-color-conservative-raster", "provider": "openrouter", "solved_at": "2026-09-23T22:17:00.067Z", "version": "20"}

Answer 2

The solution is complete and verified. Here is the solution document (the full runnable code is in ~/msdf/msdf.js and the harness in ~/msdf/verify.js; the same content including both complete source files is saved as ~/msdf/SOLUTION.md).


MSDF Atlas: Pseudodistance, Edge-Colour and Conservative-Raster Fix

Problem class: js-msdf-atlas-pseudodistance-edge-color-conservative-raster Environment: Node 20+ (developed/verified on Node 22), pure JavaScript, no native deps.

1. What is being generated

For every texel of a packed glyph atlas compute a three-channel signed distance (r,g,b) such that the median is a faithful signed distance to the glyph outline. Edges are line/quadratic/cubic segments, each assigned one of three colours (R,G,B) so adjacent segments differ. A renderer samples bilinearly and thresholds median(r,g,b) at 0.5.

Contract verified: 1. Reconstruction: coverage recovered from the atlas at 4x supersampling differs from exact analytic coverage by less than a stated per-pixel bound. 2. Edge texels: every conservatively-rasterised edge texel has at least one channel whose error vs the true signed distance is below tolerance. 3. Degenerate input: zero-length segments, duplicated points, clockwise/self-intersecting outlines produce no NaN and no sign flip. 4. Atlas border: the spread is clamped correctly and bilinear sampling never bleeds between packed glyphs.

2. Root-cause analysis

RC1 — Per-channel nearest-edge distances make the median overshoot

Storing the signed distance to the nearest edge of each colour and taking the median is wrong. Next to one edge, the other two colours' nearest edges are far away on the same side, so both store large positive values and the median becomes a far distance, not the near-edge distance. Under bilinear interpolation it crosses 0.5 in the wrong place — overshoot at acute corners and near-equidistant edges.

The reference stores a perpendicular pseudodistance: for each channel the minimum positive and maximum negative perpendicular distance to any edge of that colour, plus the perpendicular distance to its own nearest edge; it picks the smallest-magnitude value whose sign matches the true (nearest-edge) distance. At least one channel then carries the true distance and the others bracket it, so the median is correct.

RC2 — Zero-length segments flip the sign

For a linear segment with p0 == p1, ab = 0, so param = dot(aq,ab)/dot(ab,ab) = 0/0 and nonZeroSign(cross(aq,ab)) = nonZeroSign(0) = -1. The result is -|endpoint distance| for every query point, inverting the field around that vertex. Duplicated points after hinting create exactly these.

RC3 — Clockwise outer contours invert the whole field

The sign is the side of the nearest directed edge. Clockwise outers invert the entire field, so thresholding the median yields the complement (coverage error 1.0).

RC4 — Atlas border / padding

Generating only over the glyph bounding box lets bilinear sampling read undefined texels and bleed across glyphs. Distances must be clamped to the spread, each glyph rendered into a bitmap padded by spread + 1 pixels, packed with a gap, over an "outside" background.

RC5 — Conservative-raster error correction

Even the perpendicular selector leaves isolated texels where the bilinear median inverts. A conservative-raster stencil pass must flag texels where the interpolated median leaves the interval implied by its endpoints and flatten them to their median.

3. The exact fix

3.1 Perpendicular pseudodistance selector (RC1)

class PerpChannel {
  reset() {
    this.minTrueDistance = { distance: -Infinity, dot: 0 };
    this.minNegativePerpendicularDistance = -Infinity;
    this.minPositivePerpendicularDistance = Infinity;
    this.nearEdge = null; this.nearEdgeParam = 0;
  }
  addEdgeTrueDistance(edge, distance, param) {
    if (sdLess(distance, this.minTrueDistance)) {
      this.minTrueDistance = distance; this.nearEdge = edge; this.nearEdgeParam = param;
    }
  }
  addEdgePerpendicularDistance(distance) {
    if (distance <= 0 && distance > this.minNegativePerpendicularDistance)
      this.minNegativePerpendicularDistance = distance;
    if (distance >= 0 && distance < this.minPositivePerpendicularDistance)
      this.minPositivePerpendicularDistance = distance;
  }
  computeDistance(p) {
    if (this.minTrueDistance.distance === -Infinity) return Infinity; // empty colour
    let minDistance = this.minTrueDistance.distance < 0
      ? this.minNegativePerpendicularDistance
      : this.minPositivePerpendicularDistance;
    if (this.nearEdge) {
      const distance = { distance: this.minTrueDistance.distance, dot: this.minTrueDistance.dot };
      this.nearEdge.distanceToPerpendicularDistance(distance, p, this.nearEdgeParam);
      if (Math.abs(distance.distance) < Math.abs(minDistance))
        minDistance = distance.distance;
    }
    return minDistance;
  }
}

Endpoint perpendicular distances are only considered when the query lies beyond that endpoint and is closer than the true segment distance:

if (add > 0) {
  const pd = getPerp(distance.distance, ap, vmul(aDir, -1));
  if (pd !== null) for (const c of channels) c.addEdgePerpendicularDistance(-pd);
}
if (bdd > 0) {
  const pd = getPerp(distance.distance, bp, bDir);
  if (pd !== null) for (const c of channels) c.addEdgePerpendicularDistance(pd);
}

3.2 Degenerate geometry + orientation normalisation (RC2, RC3)

function edgeIsDegenerate(e) {
  const cps = controlPoints(e);
  const first = cps[0];
  for (let i = 1; i < cps.length; ++i)
    if (Math.abs(cps[i].x - first.x) > 1e-12 || Math.abs(cps[i].y - first.y) > 1e-12)
      return false;
  return true;
}
function reverseEdge(e) {
  if (e instanceof LinearEdge) { const t = e.p0; e.p0 = e.p1; e.p1 = t; }
  else if (e instanceof QuadraticEdge) { const t = e.p0; e.p0 = e.p2; e.p2 = t; }
  else if (e instanceof CubicEdge) { const a = e.p0, b = e.p1; e.p0 = e.p3; e.p1 = e.p2; e.p2 = b; e.p3 = a; }
  return e;
}
function reverseContour(c) { c.edges.reverse(); for (const e of c.edges) reverseEdge(e); }
function orientShape(shape) {
  let dominant = 0, maxAbs = 0;
  for (const c of shape.contours) {
    const a = contourSignedArea(c);
    if (Math.abs(a) > maxAbs) { maxAbs = Math.abs(a); dominant = a; }
  }
  if (dominant < 0) for (const c of shape.contours) reverseContour(c);
  return shape;
}
function sanitizeShape(shape) {
  const contours = [];
  for (const c of shape.contours) {
    const edges = [];
    for (const e of c.edges) if (!edgeIsDegenerate(e)) edges.push(e);
    if (edges.length) contours.push({ edges });
  }
  return orientShape({ contours });
}

renderGlyph calls sanitizeShape before generating, so raw input may contain duplicated points, zero-length segments and clockwise contours.

3.3 Padded, clamped atlas (RC4)

const margin = padding;                                  // padding = ceil(spread) + 1
const width  = Math.ceil((xMax - xMin) * scale + 2 * margin);
const height = Math.ceil((yMax - yMin) * scale + 2 * margin);
const originX = xMin - margin / scale;
const originY = yMax + margin / scale;                   // atlas rows go top-down
const range = { lower: -spread / scale, upper: spread / scale };
// ... per texel:
sdf[i] = clamp(mapDistance(d.r), 0, 1);                  // clamp to the spread

The packer places each already-padded glyph with a 1 px gap and fills the atlas background with 1 ("outside"), so a bilinear fetch for one glyph can never read a neighbour.

3.4 Conservative-raster error correction (RC5)

stencil.fill(PROTECTED);                                 // edge-only mode
// for every texel, test 4 axis + 4 diagonal neighbours:
if (hasLinearArtifact(hSpan, protectedFlag, cm, c, l))  flagged = true;
if (hasDiagonalArtifact(dSpan, protectedFlag, cm, c, r, b, rt)) flagged = true;
// rangeTest flags an inversion: both endpoints on one side, interpolated median on the other
// apply: pixel[0]=pixel[1]=pixel[2]=median(pixel)

4. Verification

node verify.js          # full validation suite
node /tmp/naive.js      # naive-vs-fixed comparison (optional)

The suite asserts max |reconstructed coverage - exact analytic coverage| < 0.25 at 4x4 supersampling (quantisation alone is 1/16 = 0.0625), every edge texel has a channel error < 0.05 shape units, no NaN, and the atlas border is clamped / packed glyphs do not bleed.

4.1 Measured results

=== acute-notch polygon ===
[coverage notch] scale=24 spread=4 bitmap=130x130 max|recon-exact|=0.1237 bound=0.25 PASS NaN=0
[edge texels notch] edgeTexels=1006 failures(>0.05)=0 maxBestChannelErr=0.00863 PASS

=== thin sliver (near-equidistant edges) ===
[coverage sliver] scale=24 spread=4 bitmap=164x82 max|recon-exact|=0.0682 bound=0.25 PASS NaN=0
[edge texels sliver] edgeTexels=830 failures(>0.05)=0 maxBestChannelErr=0.00863 PASS

=== star (clockwise input; orientation normalisation) ===
[coverage star] scale=20 spread=4 bitmap=210x210 max|recon-exact|=0.0792 bound=0.25 PASS NaN=0
[edge texels star] edgeTexels=1036 failures(>0.05)=0 maxBestChannelErr=0.01574 PASS

=== clockwise square ===
[coverage cw-square] scale=24 spread=4 bitmap=82x82 max|recon-exact|=0.0000 bound=0.25 PASS NaN=0
[edge texels cw-square] edgeTexels=592 failures(>0.05)=0 maxBestChannelErr=0.00863 PASS

=== degenerate contour ===
degenerate bitmap=82x82 NaN=0 PASS
[coverage degenerate] scale=24 spread=4 bitmap=82x82 max|recon-exact|=0.0625 bound=0.25 PASS NaN=0

=== atlas packing / bilinear bleed ===
atlas 256x392, 3 glyphs
atlas NaN=0 PASS
re-sample max channel diff vs standalone=0 footprintOutside=0 PASS
[atlas border clamp] outOfRange=0 farSaturated=32550/32550 PASS

4.2 The fix is the cause of the improvement

Same harness with the naive "nearest edge per channel" selector:

notch   naive max|recon-exact|=1.0000   fixed max|recon-exact|=0.1237
sliver  naive max|recon-exact|=0.0682   fixed max|recon-exact|=0.0682
star    naive max|recon-exact|=1.0000   fixed max|recon-exact|=0.0792

The 1.0 failures are exactly the acute corners / near-equidistant cases where the median of nearest-edge distances overshoots (and, for the clockwise star, the un-normalised orientation inverts the field).

5. Using the generator

const M = require('./msdf.js');
const shape = { contours: [{ edges: [ /* LinearEdge | QuadraticEdge | CubicEdge */ ] }] };
M.edgeColoringSimple(shape, Math.PI / 2, 0n);       // assign R/G/B edge colours

const glyph = M.renderGlyph(shape, { scale: 24, spread: 4 });
// glyph.pixels: Float64Array(width*height*3) with values in [0,1]
// glyph.originX / glyph.originY: shape coordinate of the bitmap's top-left texel

const atlas = M.buildAtlas(
  [{ key: 'A', shape }, { key: 'B', shape }],
  { scale: 24, spread: 4, atlasWidth: 512, gap: 1 }
);
// atlas.pixels, atlas.width, atlas.height, atlas.entries[i].placement

Decode a channel with d = v * (2*spread/scale) - spread/scale; the glyph is inside where median(r,g,b) < 0.5.

6. Files

Evidence & signatures

# Evidence
- Problem class: js-msdf-atlas-pseudodistance-edge-color-conservative-raster
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-23T22:17:00.066Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Generate a multi-channel signed distance field (MSDF) atlas from vector glyph outlines: for every texel compute the true signed distance to the nearest edge and encode per-channel pseudodistances so that at least one channel carries a correct distance near every edge, including at acute corners and where two edges are near-equidistant, which is what prevents bilinear reconstruction of the median from overshooting. Handle degenerate contours (zero-length segments, duplicated points, self-intersecting outlines after hinting), a configurable spread with correct clamping at the atlas border, and glyph packing with padding so bilinear sampling never bleeds between glyphs. Validate by reconstructing the outline from the atlas at 4x supersampling and asserting that coverage differs from an exact analytic coverage by less than a stated per-pixel bound, and by asserting every edge texel has at least one channel whose error is below tolerance.", "environment": "node20", "language": "js", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "js-msdf-atlas-pseudodistance-edge-color-conservative-raster", "provider": "openrouter", "solved_at": "2026-09-23T22:17:00.067Z", "version": "20"}
Generated from the verified corpus · MIT licensedBack to the catalog