Repository: mozilla/pdf.js
File: src/core/pattern.js (JavaScript)

Code before:
        colorStops.push([iPrev / NUMBER_OF_SAMPLES, cssColor]);

        // TODO: When fn frequency is high (iPrev - iBase === 1 twice in a row),
        // send the color space and function to do the sampling display side.

        // The run is i - iPrev = 1, so omitted.
        maxSlopeR = r - rPrev + 1;
        maxSlopeG = g - gPrev + 1;
        maxSlopeB = b - bPrev + 1;
        minSlopeR = r - rPrev - 1;
        minSlopeG = g - gPrev - 1;
        minSlopeB = b - bPrev - 1;

        iBase = iPrev;
        rBase = rPrev;
        gBase = gPrev;
        bBase = bPrev;
      }

      iPrev = i;
      rPrev = r;
      gPrev = g;
      bPrev = b;
    }
    const cssColor = Util.makeHexColor(rPrev, gPrev, bPrev);
    colorStops.push([1, cssColor]);

    let background = "transparent";
    if (dict.has("Background")) {
      background = cs.getRgbHex(dict.get("Background"), 0);
    }

    if (!extendStart) {
      // Insert a color stop at the front and offset the first real color stop
      // so it doesn't conflict with the one we insert.
      colorStops.unshift([0, background]);
      colorStops[1][0] += BaseShading.SMALL_NUMBER;
    }
    if (!extendEnd) {
      // Same idea as above in extendStart but for the end.
      colorStops.at(-1)[0] -= BaseShading.SMALL_NUMBER;
      colorStops.push([1, background]);
    }

    this.colorStops = colorStops;
  }

  getIR() {
    const { coordsArr, shadingType } = this;
    let type, p0, p1, r0, r1;
    if (shadingType === ShadingType.AXIAL) {

Review comment (suggestion):
Nit: Maybe just inline this, similar to how it's done [above in the patch](https://github.com/mozilla/pdf.js/pull/19953/files#diff-4b728b263d79e162b6b7bcd69b7cd3db371c6d5bcde01e207b03ee13596ae940R210)?
```suggestion
    colorStops.push([1, Util.makeHexColor(rPrev, gPrev, bPrev)]);
```

Code after:
        maxSlopeR = r - rPrev + 1;
        maxSlopeG = g - gPrev + 1;
        maxSlopeB = b - bPrev + 1;
        minSlopeR = r - rPrev - 1;
        minSlopeG = g - gPrev - 1;
        minSlopeB = b - bPrev - 1;

        iBase = iPrev;
        rBase = rPrev;
        gBase = gPrev;
        bBase = bPrev;
      }

      iPrev = i;
      rPrev = r;
      gPrev = g;
      bPrev = b;
    }
    colorStops.push([1, Util.makeHexColor(rPrev, gPrev, bPrev)]);

    let background = "transparent";
    if (dict.has("Background")) {
      background = cs.getRgbHex(dict.get("Background"), 0);
    }

    if (!extendStart) {
      // Insert a color stop at the front and offset the first real color stop
      // so it doesn't conflict with the one we insert.
      colorStops.unshift([0, background]);
      colorStops[1][0] += BaseShading.SMALL_NUMBER;
    }
    if (!extendEnd) {
      // Same idea as above in extendStart but for the end.
      colorStops.at(-1)[0] -= BaseShading.SMALL_NUMBER;
      colorStops.push([1, background]);
    }

    this.colorStops = colorStops;
  }

  getIR() {
    const { coordsArr, shadingType } = this;
    let type, p0, p1, r0, r1;
    if (shadingType === ShadingType.AXIAL) {
      p0 = [coordsArr[0], coordsArr[1]];
      p1 = [coordsArr[2], coordsArr[3]];
      r0 = null;
      r1 = null;
      type = "axial";
    } else if (shadingType === ShadingType.RADIAL) {
      p0 = [coordsArr[0], coordsArr[1]];