@carto/api-client 0.5.32-alpha.48cef4f.127 → 0.5.32-alpha.5d97a52.131

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.
@@ -10743,6 +10743,7 @@ var solid_default = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAA
10743
10743
 
10744
10744
  // src/fetch-map/pattern-atlas.ts
10745
10745
  var DEFAULT_CELL_SIZE = 128;
10746
+ var SOURCE_TILE_SIZE = 64;
10746
10747
  var PATTERN_ROWS = [
10747
10748
  "hlines",
10748
10749
  "vlines",
@@ -10788,11 +10789,22 @@ function getPatternTextureParameters() {
10788
10789
  const params = debugGlobals().__CARTO_PATTERN_TEXTURE_PARAMS__;
10789
10790
  return params && typeof params === "object" ? params : void 0;
10790
10791
  }
10792
+ function getPatternRepeats(cell) {
10793
+ return Math.max(1, Math.floor(cell / SOURCE_TILE_SIZE));
10794
+ }
10795
+ function getPatternScaleAdjustment(cell = getPatternCellSize()) {
10796
+ return SOURCE_TILE_SIZE * getPatternRepeats(cell) / cell;
10797
+ }
10798
+ function getPatternCellPadding(cell) {
10799
+ return Math.max(2, Math.round(cell / 16));
10800
+ }
10791
10801
  function getPatternAtlasMapping(cell = getPatternCellSize()) {
10802
+ const pad = getPatternCellPadding(cell);
10803
+ const pitch = cell + 2 * pad;
10792
10804
  const mapping = {};
10793
10805
  const frame = (col, row) => ({
10794
- x: col * cell,
10795
- y: row * cell,
10806
+ x: pad + col * pitch,
10807
+ y: pad + row * pitch,
10796
10808
  width: cell,
10797
10809
  height: cell,
10798
10810
  mask: true
@@ -10843,7 +10855,9 @@ function getPatternAtlas(cell = getPatternCellSize()) {
10843
10855
  }
10844
10856
  async function build(cell) {
10845
10857
  const mapping = getPatternAtlasMapping(cell);
10846
- const canvas = createCanvas(cell * 3, cell * (PATTERN_ROWS.length + 1));
10858
+ const pad = getPatternCellPadding(cell);
10859
+ const pitch = cell + 2 * pad;
10860
+ const canvas = createCanvas(pitch * 3, pitch * (PATTERN_ROWS.length + 1));
10847
10861
  const ctx = canvas.getContext("2d");
10848
10862
  if (!ctx)
10849
10863
  throw new Error(
@@ -10855,10 +10869,21 @@ async function build(cell) {
10855
10869
  images[key] = await loadImage(url);
10856
10870
  })
10857
10871
  );
10858
- ctx.imageSmoothingEnabled = false;
10872
+ const reps = getPatternRepeats(cell);
10873
+ const step = cell / reps;
10859
10874
  for (const [key, frame] of Object.entries(mapping)) {
10860
10875
  const img = images[key];
10861
- if (img) ctx.drawImage(img, frame.x, frame.y, cell, cell);
10876
+ if (!img) continue;
10877
+ ctx.save();
10878
+ ctx.beginPath();
10879
+ ctx.rect(frame.x - pad, frame.y - pad, cell + 2 * pad, cell + 2 * pad);
10880
+ ctx.clip();
10881
+ for (let i = -1; i <= reps; i++) {
10882
+ for (let j = -1; j <= reps; j++) {
10883
+ ctx.drawImage(img, frame.x + i * step, frame.y + j * step, step, step);
10884
+ }
10885
+ }
10886
+ ctx.restore();
10862
10887
  }
10863
10888
  if (typeof createImageBitmap !== "undefined")
10864
10889
  return createImageBitmap(canvas);
@@ -11299,7 +11324,7 @@ function createChannelProps(id, layerType, config2, visualChannels, data, datase
11299
11324
  if (textureParameters) {
11300
11325
  result.textureParameters = textureParameters;
11301
11326
  }
11302
- result.getFillPatternScale = visConfig.fillPatternSize ?? 1;
11327
+ result.getFillPatternScale = (visConfig.fillPatternSize ?? 1) * getPatternScaleAdjustment();
11303
11328
  result.fillPattern = visConfig.fillPattern;
11304
11329
  const { fillPatternField, fillPatternScale } = visualChannels;
11305
11330
  const { fillPatternRange, fillPatternDensity } = visConfig;