@carto/api-client 0.5.32-alpha.5d97a52.131 → 0.5.32-alpha.72cdcfe.130

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.
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "homepage": "https://github.com/CartoDB/carto-api-client#readme",
9
9
  "author": "Don McCurdy <donmccurdy@carto.com>",
10
10
  "packageManager": "yarn@4.3.1",
11
- "version": "0.5.32-alpha.5d97a52.131",
11
+ "version": "0.5.32-alpha.72cdcfe.130",
12
12
  "license": "MIT",
13
13
  "publishConfig": {
14
14
  "access": "public"
@@ -1,13 +1,12 @@
1
1
  // Fill-pattern atlas — internal to carto-api-client.
2
2
  //
3
3
  // The patterns live as individual, developer-editable tiles (src/fetch-map/patterns/
4
- // *.png — anti-aliased exports from the Design vector master), inlined by tsup's
5
- // `dataurl` loader and composited into a sprite sheet on a canvas the first time a
6
- // pattern is needed. Each atlas cell is filled with side-by-side native-resolution
7
- // copies of its tile (never resampled), and is surrounded by a gutter holding the
8
- // tile's own wrapped content so linear sampling stays seamless at repeat boundaries
9
- // and never bleeds a neighboring cell. Cell size should be a multiple of the source
10
- // tile size.
4
+ // *.png — any resolution; ideally anti-aliased exports from the Design vector master),
5
+ // inlined by tsup's `dataurl` loader and composited into a sprite sheet on a canvas the
6
+ // first time a pattern is needed. Each cell is surrounded by a gutter filled with the
7
+ // tile's own wrapped content, so linear sampling stays seamless at repeat boundaries
8
+ // and never bleeds a neighboring cell. High-res sources are smoothly downscaled;
9
+ // lower-res (pixel-art) sources are upscaled nearest-neighbor.
11
10
  //
12
11
  // parse-map sets `result.fillPatternAtlas = getPatternAtlas()`. deck.gl's
13
12
  // `fillPatternAtlas` prop is async — but the Promise must resolve to a decoded image,
@@ -116,22 +115,14 @@ export function getPatternTextureParameters():
116
115
  return params && typeof params === 'object' ? params : undefined;
117
116
  }
118
117
 
119
- // Copies of the source tile laid side by side inside one atlas cell, per axis. The
120
- // tile draws at native resolution (no resampling) and the UV wrap — where sampling
121
- // seams live — happens 1/reps as often.
122
- function getPatternRepeats(cell: number): number {
123
- return Math.max(1, Math.floor(cell / SOURCE_TILE_SIZE));
124
- }
125
-
126
118
  // deck's fill-pattern shader sizes the on-screen repeat proportionally to the mapping
127
- // frame's texel size (scale = FILL_UV_SCALE * getFillPatternScale * frame.wh). This
128
- // factor compensates for both the cell size and the repeats inside it, so the design
129
- // tile keeps a constant on-screen size; it is exactly 1 when cell is a multiple of
130
- // the source tile size.
119
+ // frame's texel size (scale = FILL_UV_SCALE * getFillPatternScale * frame.wh), so a
120
+ // bigger cell magnifies the art instead of sharpening it. This factor compensates:
121
+ // getFillPatternScale must be multiplied by it so cell size only changes resolution.
131
122
  export function getPatternScaleAdjustment(
132
123
  cell: number = getPatternCellSize()
133
124
  ): number {
134
- return (SOURCE_TILE_SIZE * getPatternRepeats(cell)) / cell;
125
+ return SOURCE_TILE_SIZE / cell;
135
126
  }
136
127
 
137
128
  // Gutter width around each cell; sized so a few mip levels stay bleed-free.
@@ -232,21 +223,23 @@ async function build(cell: number): Promise<AssembledAtlas> {
232
223
  })
233
224
  );
234
225
 
235
- // `none` is left transparent (no tile). Every other cell is filled with reps x reps
236
- // native-resolution copies of its tile never upscaled with one extra ring
237
- // clipped into the gutter, so the padding holds the tile's own wrapped content.
238
- const reps = getPatternRepeats(cell);
239
- const step = cell / reps;
226
+ // `none` is left transparent (no tile). Every other tile is drawn 3x3 clipped to its
227
+ // padded rect, so the gutter holds the tile's own wrapped content.
240
228
  for (const [key, frame] of Object.entries(mapping)) {
241
229
  const img = images[key];
242
230
  if (!img) continue;
231
+ // Two art classes: diagonal tiles rely on baked anti-aliasing, which nearest
232
+ // scaling turns into hard blocks — scale them smoothly. Axis-aligned tiles have
233
+ // exact hard edges on texel boundaries — nearest is lossless, smoothing blurs.
234
+ ctx.imageSmoothingEnabled = /^(diag-|cross-hatch)/.test(key);
235
+ if ('imageSmoothingQuality' in ctx) ctx.imageSmoothingQuality = 'high';
243
236
  ctx.save();
244
237
  ctx.beginPath();
245
238
  ctx.rect(frame.x - pad, frame.y - pad, cell + 2 * pad, cell + 2 * pad);
246
239
  ctx.clip();
247
- for (let i = -1; i <= reps; i++) {
248
- for (let j = -1; j <= reps; j++) {
249
- ctx.drawImage(img, frame.x + i * step, frame.y + j * step, step, step);
240
+ for (const dx of [-cell, 0, cell]) {
241
+ for (const dy of [-cell, 0, cell]) {
242
+ ctx.drawImage(img, frame.x + dx, frame.y + dy, cell, cell);
250
243
  }
251
244
  }
252
245
  ctx.restore();