azulejeria 2.4.0 → 2.5.0
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/README.md +11 -0
- package/package.json +1 -1
- package/src/azulejeria.js +59 -0
package/README.md
CHANGED
|
@@ -185,6 +185,17 @@ edge across the far corner, which four tiles close into a ring or a
|
|
|
185
185
|
diamond), `ring` (a scalloped ring around the main corner), `lattice` (a
|
|
186
186
|
line edge to edge that mirrors into a lozenge net) and `dots`.
|
|
187
187
|
|
|
188
|
+
**A border round a corner**: `bendCorner(strip, fill)` takes a square
|
|
189
|
+
tile painted as a run of border (outside along the top, inside along
|
|
190
|
+
the bottom, the design meeting itself left and right) and returns the
|
|
191
|
+
corner tile: the strip bent through a quarter turn about its inner
|
|
192
|
+
corner, so the vine or the scroll turns the corner and meets the strip
|
|
193
|
+
on both sides. `fill(g, size)`, if given, paints the outer corner the
|
|
194
|
+
bend does not reach. [Azulejos de letras](https://stepinto.dev/art/letras.html)
|
|
195
|
+
uses it for the frame of a street plaque. `mitreCorner(strip)` is the
|
|
196
|
+
square alternative: the strip cut on the diagonal and laid both ways,
|
|
197
|
+
as a run of border tiles is mitred at forty-five degrees.
|
|
198
|
+
|
|
188
199
|
**The lower level** is there if you want it: `makeDesign(seed, density,
|
|
189
200
|
bands, bold, motif)`, `paintDesign(g, els, pal, hand, lw, seed, painters, material, brush)`,
|
|
190
201
|
`makeTile(opts, size, pixelRatio, seed)`, `tileOpts(cfg, state)` and
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "azulejeria",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Tin-glazed tiles painted by rule. A seeded canvas engine for Spanish azulejo walls: a diagonal-symmetric design, brushwork that drifts, washes that pool, and four ways to repeat the tile.",
|
|
5
5
|
"keywords": ["canvas", "generative", "wallpaper-groups", "symmetry", "tiles", "azulejo", "mudejar", "sevilla", "pattern", "procedural", "art", "wallpaper", "interlace", "knotwork", "celtic", "mosaic", "voronoi", "trencadis"],
|
|
6
6
|
"license": "MIT",
|
package/src/azulejeria.js
CHANGED
|
@@ -364,6 +364,65 @@ export function ageTile(ctx, rng, s, pal) {
|
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
+
// A border tile bent round a corner. `strip` is a square tile painted
|
|
368
|
+
// as a run of border: the outside of the wall along its top edge, the
|
|
369
|
+
// inside along its bottom, the design meeting itself at left and
|
|
370
|
+
// right. The corner is the quarter-annulus about the tile's inner
|
|
371
|
+
// corner: distance from that corner becomes how far in the design
|
|
372
|
+
// sits, and the angle round it becomes how far along, so the strip's
|
|
373
|
+
// right edge becomes the corner's right edge, its left edge the
|
|
374
|
+
// corner's bottom edge, and the design turns through a quarter between
|
|
375
|
+
// them. Where the annulus does not reach, the outer corner, `fill(g)`
|
|
376
|
+
// paints the ground (the glaze by default, sampled from the strip's
|
|
377
|
+
// own corner). The result joins the strip laid to its right unturned
|
|
378
|
+
// and laid below it turned three quarters; the other three corners are
|
|
379
|
+
// this one turned.
|
|
380
|
+
export function bendCorner(strip, fill) {
|
|
381
|
+
const N = strip.width;
|
|
382
|
+
const c = document.createElement('canvas');
|
|
383
|
+
c.width = c.height = N;
|
|
384
|
+
const g = c.getContext('2d');
|
|
385
|
+
if (fill) fill(g, N);
|
|
386
|
+
else { g.drawImage(strip, 0, 0, 2, 2, 0, 0, N, N); }
|
|
387
|
+
const src = strip.getContext('2d').getImageData(0, 0, N, N).data;
|
|
388
|
+
const out = g.getImageData(0, 0, N, N), d = out.data;
|
|
389
|
+
const Q = Math.PI / 2;
|
|
390
|
+
for (let py = 0; py < N; py++) for (let px = 0; px < N; px++) {
|
|
391
|
+
const u = 1 - (px + 0.5) / N, v = 1 - (py + 0.5) / N;
|
|
392
|
+
const r = Math.hypot(u, v);
|
|
393
|
+
if (r > 1) continue;
|
|
394
|
+
const along = Math.atan2(u, v) / Q, inward = 1 - r;
|
|
395
|
+
// bilinear sample of the strip at (along, inward)
|
|
396
|
+
const sx = Math.min(N - 1.001, Math.max(0, along * N - 0.5)), sy = Math.min(N - 1.001, Math.max(0, inward * N - 0.5));
|
|
397
|
+
const x0 = Math.floor(sx), y0 = Math.floor(sy), fx = sx - x0, fy = sy - y0;
|
|
398
|
+
const i = (py * N + px) * 4;
|
|
399
|
+
for (let ch = 0; ch < 4; ch++) {
|
|
400
|
+
const a = src[(y0 * N + x0) * 4 + ch], b = src[(y0 * N + x0 + 1) * 4 + ch];
|
|
401
|
+
const cc = src[((y0 + 1) * N + x0) * 4 + ch], dd = src[((y0 + 1) * N + x0 + 1) * 4 + ch];
|
|
402
|
+
d[i + ch] = (a * (1 - fx) + b * fx) * (1 - fy) + (cc * (1 - fx) + dd * fx) * fy;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
g.putImageData(out, 0, 0);
|
|
406
|
+
return c;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// The same strip mitred instead: the corner is cut on the diagonal
|
|
410
|
+
// from the outer corner to the inner one, the strip laid unturned
|
|
411
|
+
// above the cut and turned three quarters below it, the way a picture
|
|
412
|
+
// frame or a run of border tiles is cut at forty-five degrees. It joins
|
|
413
|
+
// the same neighbours as bendCorner's.
|
|
414
|
+
export function mitreCorner(strip) {
|
|
415
|
+
const N = strip.width;
|
|
416
|
+
const c = document.createElement('canvas');
|
|
417
|
+
c.width = c.height = N;
|
|
418
|
+
const g = c.getContext('2d');
|
|
419
|
+
g.save(); g.beginPath(); g.moveTo(0, 0); g.lineTo(N, 0); g.lineTo(N, N); g.closePath(); g.clip();
|
|
420
|
+
g.drawImage(strip, 0, 0); g.restore();
|
|
421
|
+
g.save(); g.beginPath(); g.moveTo(0, 0); g.lineTo(0, N); g.lineTo(N, N); g.closePath(); g.clip();
|
|
422
|
+
g.translate(N / 2, N / 2); g.rotate(3 * Math.PI / 2); g.drawImage(strip, -N / 2, -N / 2); g.restore();
|
|
423
|
+
return c;
|
|
424
|
+
}
|
|
425
|
+
|
|
367
426
|
// a wall laid by a wallpaper group: every copy of the domain in every
|
|
368
427
|
// cell the window touches, each straying from its place as the hand
|
|
369
428
|
// allows, aged if asked. `pick(rng)` chooses the tile image.
|