fix(live): globe sea and land colors, world map antimeridian rings
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and vet (push) Successful in 22s
CI / Tests (Linux, race detector) (push) Successful in 33s
CI / Dependency audit (push) Successful in 13s
Release / Plan (reuse the published image?) (push) Successful in 3s
Release / ci (push) Skipped
Release / Build image (amd64) (push) Skipped
Release / Build image (arm64) (push) Skipped
Release / Publish tags (push) Successful in 14s
Release / Gitea release (push) Successful in 3s
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and vet (push) Successful in 22s
CI / Tests (Linux, race detector) (push) Successful in 33s
CI / Dependency audit (push) Successful in 13s
Release / Plan (reuse the published image?) (push) Successful in 3s
Release / ci (push) Skipped
Release / Build image (amd64) (push) Skipped
Release / Build image (arm64) (push) Skipped
Release / Publish tags (push) Successful in 14s
Release / Gitea release (push) Successful in 3s
The globe clipped country rings by pushing hidden vertices to the limb and closing them with chords, so the fill flipped between sea and land as it turned. Rings are now clipped at the horizon and closed along the limb in their own orientation; the path parser returns to the subpath start after z; long edges follow the map projection. gen-world.mjs unwraps longitudes and clips rings that cross the 180th meridian (Russia, Fiji) at the map edge instead of leaving them open, which filled the Sea of Okhotsk as land. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
783b0cba3e
commit
8f1ac462d1
6 files changed
+157
-33
No files matched your search
@@ -6,6 +6,13 @@ Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versio
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [1.1.1] - 2026-11-14
|
||||
|
||||
### Fixed
|
||||
|
||||
- Live page, globe mode: sea and land colors no longer swap while the globe turns. Each country ring is now clipped at the horizon and closed along the edge of the globe, and long edges follow the map projection.
|
||||
- World map data: countries crossing the 180th meridian (Russia, Fiji) are closed along the map edge, so the Sea of Okhotsk is no longer filled as land on the flat maps.
|
||||
|
||||
## [1.1.0] - 2026-11-14
|
||||
|
||||
### Added
|
||||
|
||||
@@ -6,6 +6,13 @@ Formato baseado no [Keep a Changelog](https://keepachangelog.com/pt-BR/1.1.0/);
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [1.1.1] - 2026-11-14
|
||||
|
||||
### Corrigido
|
||||
|
||||
- Página Ao vivo, modo globo: as cores do mar e da terra não se trocam mais enquanto o globo gira. Cada contorno de país agora é recortado no horizonte e fechado ao longo da borda do globo, e as arestas longas seguem a projeção do mapa.
|
||||
- Dados do mapa-múndi: países que cruzam o meridiano 180 (Rússia, Fiji) são fechados ao longo da borda do mapa, então o Mar de Okhotsk não é mais pintado como terra nos mapas planos.
|
||||
|
||||
## [1.1.0] - 2026-11-14
|
||||
|
||||
### Adicionado
|
||||
|
||||
@@ -2,4 +2,4 @@ package app
|
||||
|
||||
// Version is the release version (SemVer). Release builds may override it with
|
||||
// -ldflags "-X .../internal/app.Version=...".
|
||||
var Version = "1.1.0"
|
||||
var Version = "1.1.1"
|
||||
+90
-21
@@ -98,14 +98,14 @@
|
||||
var rings = [], total = 0;
|
||||
var re = /([MmLlHhVvZz])|(-?\d*\.?\d+)/g;
|
||||
Object.keys(world.paths).forEach(function (cc) {
|
||||
var d = world.paths[cc], m, cmd = '', nums = [], cur = null, x = 0, y = 0;
|
||||
var d = world.paths[cc], m, cmd = '', nums = [], cur = null, x = 0, y = 0, sx = 0, sy = 0;
|
||||
function flush() {
|
||||
if (!cmd) return;
|
||||
var up = cmd.toUpperCase(), rel = cmd !== up, i;
|
||||
if (up === 'M' || up === 'L') {
|
||||
for (i = 0; i + 1 < nums.length; i += 2) {
|
||||
x = rel ? x + nums[i] : nums[i]; y = rel ? y + nums[i + 1] : nums[i + 1];
|
||||
if (up === 'M' && i === 0) { cur = [[x, y]]; rings.push(cur); } else if (cur) cur.push([x, y]);
|
||||
if (up === 'M' && i === 0) { cur = [[x, y]]; rings.push(cur); sx = x; sy = y; } else if (cur) cur.push([x, y]);
|
||||
}
|
||||
} else if (up === 'H') { nums.forEach(function (n) { x = rel ? x + n : n; if (cur) cur.push([x, y]); }); }
|
||||
else if (up === 'V') { nums.forEach(function (n) { y = rel ? y + n : n; if (cur) cur.push([x, y]); }); }
|
||||
@@ -113,7 +113,7 @@
|
||||
}
|
||||
re.lastIndex = 0;
|
||||
while ((m = re.exec(d))) {
|
||||
if (m[1]) { flush(); cmd = m[1]; if (cmd === 'z' || cmd === 'Z') cmd = ''; }
|
||||
if (m[1]) { flush(); cmd = m[1]; if (cmd === 'z' || cmd === 'Z') { cmd = ''; x = sx; y = sy; } } // after z the pen returns to the subpath start
|
||||
else nums.push(parseFloat(m[2]));
|
||||
}
|
||||
flush();
|
||||
@@ -126,21 +126,37 @@
|
||||
pts.push(p); last = p;
|
||||
});
|
||||
if (pts.length < 3) return;
|
||||
var n = pts.length, v = new Float32Array(n * 3), edge = new Uint8Array(n);
|
||||
for (var i = 0; i < n; i++) {
|
||||
var lon = pts[i][0] / WORLD_W * 360 - 180, lat = LAT_TOP - pts[i][1] / WORLD_H * (LAT_TOP - LAT_BOT);
|
||||
var cl = Math.cos(lat * RAD);
|
||||
v[i * 3] = cl * Math.sin(lon * RAD); v[i * 3 + 1] = Math.sin(lat * RAD); v[i * 3 + 2] = cl * Math.cos(lon * RAD);
|
||||
var q = pts[(i + n - 1) % n];
|
||||
// orientation in lon/lat space (y up): ccw when the shoelace sum of the map (y down) is negative
|
||||
var area = 0, k0;
|
||||
for (k0 = 0; k0 < pts.length; k0++) { var pa = pts[k0], pb = pts[(k0 + 1) % pts.length]; area += pa[0] * pb[1] - pb[0] * pa[1]; }
|
||||
var items = []; // [x, y, z, edge]
|
||||
for (var i = 0; i < pts.length; i++) {
|
||||
var q = pts[(i + pts.length - 1) % pts.length];
|
||||
// segments lying on the map border (antimeridian cut) or on the clipped
|
||||
// southern edge are not borders: they are not stroked on the globe
|
||||
if ((pts[i][0] < 1.5 && q[0] < 1.5) || (pts[i][0] > WORLD_W - 1.5 && q[0] > WORLD_W - 1.5) ||
|
||||
(pts[i][1] > WORLD_H - 1.5 && q[1] > WORLD_H - 1.5)) edge[i] = 1;
|
||||
var onEdge = ((pts[i][0] < 1.5 && q[0] < 1.5) || (pts[i][0] > WORLD_W - 1.5 && q[0] > WORLD_W - 1.5) ||
|
||||
(pts[i][1] > WORLD_H - 1.5 && q[1] > WORLD_H - 1.5)) ? 1 : 0;
|
||||
// a ring that runs along the clipped southern edge across the whole map
|
||||
// (Antarctica) really wraps around the pole: go through it
|
||||
if (pts[i][1] > WORLD_H - 1.5 && q[1] > WORLD_H - 1.5 && Math.abs(pts[i][0] - q[0]) > WORLD_W * 0.5) items.push([0, -1, 0, 1]);
|
||||
// long edges follow the straight line of the flat map (which is how the data
|
||||
// is drawn there), so they are cut into short pieces rather than one 3D chord
|
||||
var dd = Math.sqrt((pts[i][0] - q[0]) * (pts[i][0] - q[0]) + (pts[i][1] - q[1]) * (pts[i][1] - q[1])), steps = Math.min(200, Math.ceil(dd / 10));
|
||||
if (dd > 60) onEdge = 1; // a closing chord of the data, not a coastline: no outline
|
||||
if (Math.abs(pts[i][0] - q[0]) > WORLD_W * 0.5) steps = 1; // wraps the antimeridian: keep it a single edge
|
||||
for (var sIdx = 1; sIdx <= steps; sIdx++) {
|
||||
var f = sIdx / steps, mx = q[0] + (pts[i][0] - q[0]) * f, my = q[1] + (pts[i][1] - q[1]) * f;
|
||||
var lon = mx / WORLD_W * 360 - 180, lat = LAT_TOP - my / WORLD_H * (LAT_TOP - LAT_BOT);
|
||||
var cl = Math.cos(lat * RAD);
|
||||
items.push([cl * Math.sin(lon * RAD), Math.sin(lat * RAD), cl * Math.cos(lon * RAD), onEdge]);
|
||||
}
|
||||
}
|
||||
out.push({ v: v, edge: edge, n: n });
|
||||
var n = items.length, v = new Float32Array(n * 3), edge = new Uint8Array(n);
|
||||
for (var j = 0; j < n; j++) { v[j * 3] = items[j][0]; v[j * 3 + 1] = items[j][1]; v[j * 3 + 2] = items[j][2]; edge[j] = items[j][3]; }
|
||||
out.push({ v: v, edge: edge, n: n, ccw: area < 0 });
|
||||
total += n;
|
||||
});
|
||||
geo = { rings: out, total: total, scratch: new Float32Array(total * 3) };
|
||||
geo = { rings: out, total: total, scratch: new Float32Array(total * 3), maxN: out.reduce(function (m, r) { return Math.max(m, r.n); }, 0) };
|
||||
return geo;
|
||||
}
|
||||
|
||||
@@ -210,6 +226,7 @@
|
||||
this.build();
|
||||
this.readTheme();
|
||||
this.resize();
|
||||
if (window.__URUTAU_LIVE_TEST) window.__URUTAU_LIVE_TEST.inst = this; // test hook, unset in production
|
||||
|
||||
this.unsub = U.onEvent ? U.onEvent(function (e) { self.ingest(e); }) : null;
|
||||
this.listen(document, 'visibilitychange', function () { self.onVisibility(); });
|
||||
@@ -956,6 +973,61 @@
|
||||
this.rx = x1; this.ry = y * this.cp - z1 * this.sp; this.rz = y * this.sp + z1 * this.cp;
|
||||
};
|
||||
|
||||
// Adds one ring (unit-sphere view coordinates x, y, z at sc[base..]) to the current
|
||||
// path, clipped to the visible hemisphere: edges that cross the horizon are cut
|
||||
// where they meet it and the gap is closed by an arc along the limb, walked in the
|
||||
// ring's own direction, so the fill never covers the wrong side.
|
||||
P.clipRing = function (g, sc, base, n, ccw, cx, cy, R) {
|
||||
var j, p, q, runs = [], TWO = Math.PI * 2, EPS = 0.015; // a hair above the horizon: grazing vertices would give unstable cut points
|
||||
function limb(a, b) { // where edge a->b meets z = 0, on the unit circle
|
||||
var t = (sc[a + 2] - EPS) / (sc[a + 2] - sc[b + 2]);
|
||||
var x = sc[a] + (sc[b] - sc[a]) * t, y = sc[a + 1] + (sc[b + 1] - sc[a + 1]) * t, h = Math.sqrt(x * x + y * y) || 1;
|
||||
return [x / h, y / h];
|
||||
}
|
||||
for (j = 0; j < n; j++) {
|
||||
p = base + ((j + n - 1) % n) * 3; q = base + j * 3;
|
||||
if (sc[q + 2] > EPS && sc[p + 2] <= EPS) {
|
||||
var len = 1;
|
||||
while (len < n && sc[base + ((j + len) % n) * 3 + 2] > EPS) len++;
|
||||
var last = base + ((j + len - 1) % n) * 3, nxt = base + ((j + len) % n) * 3;
|
||||
var en = limb(p, q), ex = limb(last, nxt);
|
||||
runs.push({ s: j, len: len, en: en, ex: ex, ae: Math.atan2(-en[1], en[0]), ax: Math.atan2(-ex[1], ex[0]), done: false });
|
||||
}
|
||||
}
|
||||
if (!runs.length) {
|
||||
if (sc[base + 2] <= EPS) return; // wholly hidden
|
||||
for (j = 0; j < n; j++) { q = base + j * 3; if (j) g.lineTo(cx + sc[q] * R, cy - sc[q + 1] * R); else g.moveTo(cx + sc[q] * R, cy - sc[q + 1] * R); }
|
||||
g.closePath();
|
||||
return;
|
||||
}
|
||||
// Stitch the visible runs into closed contours the way a polygon clipper does:
|
||||
// from where a run leaves the disc, follow the limb in the ring's own direction
|
||||
// to the nearest point where some run comes back in.
|
||||
for (var r0 = 0; r0 < runs.length; r0++) {
|
||||
if (runs[r0].done) continue;
|
||||
var run = runs[r0];
|
||||
g.moveTo(cx + run.en[0] * R, cy - run.en[1] * R);
|
||||
for (;;) {
|
||||
run.done = true;
|
||||
for (var k = 0; k < run.len; k++) { q = base + ((run.s + k) % n) * 3; g.lineTo(cx + sc[q] * R, cy - sc[q + 1] * R); }
|
||||
g.lineTo(cx + run.ex[0] * R, cy - run.ex[1] * R);
|
||||
var best = null, bd = 1e9;
|
||||
for (var m = 0; m < runs.length; m++) {
|
||||
var d = ccw ? run.ax - runs[m].ae : runs[m].ae - run.ax;
|
||||
d = ((d % TWO) + TWO) % TWO;
|
||||
// an arc of almost a full turn is a rounding artefact (the cut points of a sliver
|
||||
// came out in the wrong order): walk the short way back instead
|
||||
if (d > TWO * 0.95) d -= TWO;
|
||||
if (d < bd) { bd = d; best = runs[m]; }
|
||||
}
|
||||
g.arc(cx, cy, R, run.ax, best.ae, bd < 0 ? !ccw : !!ccw);
|
||||
if (best === runs[r0] || best.done) break;
|
||||
run = best;
|
||||
}
|
||||
g.closePath();
|
||||
}
|
||||
};
|
||||
|
||||
P.drawGlobeBase = function (g, m) {
|
||||
var cx = this.cx, cy = this.cy, R = this.gR, acc = this.pal.accent, tx = this.pal.text, dark = this.dark;
|
||||
var lat, lon, k, up, cl;
|
||||
@@ -992,16 +1064,13 @@
|
||||
var rings = this.geo.rings, sc = this.geo.scratch, o = 0, i, j;
|
||||
g.beginPath();
|
||||
for (i = 0; i < rings.length; i++) {
|
||||
var r = rings[i], v = r.v, n = r.n;
|
||||
var r = rings[i], v = r.v, n = r.n, base = o;
|
||||
// rotate every vertex (true screen position and depth, nothing pinned)
|
||||
for (j = 0; j < n; j++) {
|
||||
this.rot(v[j * 3], v[j * 3 + 1], v[j * 3 + 2]);
|
||||
var sx = this.rx, sy = this.ry, z = this.rz;
|
||||
if (z < 0) { var hl = Math.sqrt(sx * sx + sy * sy) || 1; sx /= hl; sy /= hl; } // hidden side: pinned to the limb
|
||||
sc[o] = cx + sx * R; sc[o + 1] = cy - sy * R; sc[o + 2] = z;
|
||||
if (j === 0) g.moveTo(sc[o], sc[o + 1]); else g.lineTo(sc[o], sc[o + 1]);
|
||||
o += 3;
|
||||
sc[o] = this.rx; sc[o + 1] = this.ry; sc[o + 2] = this.rz; o += 3;
|
||||
}
|
||||
g.closePath();
|
||||
this.clipRing(g, sc, base, n, r.ccw, cx, cy, R);
|
||||
}
|
||||
g.fillStyle = rgba(tx, 0.2); g.fill();
|
||||
g.strokeStyle = rgba(tx, dark ? 0.38 : 0.45); g.lineWidth = 0.8; g.beginPath();
|
||||
@@ -1010,7 +1079,7 @@
|
||||
var e = rings[i].edge, n2 = rings[i].n;
|
||||
for (j = 1; j <= n2; j++) {
|
||||
var p = (j - 1) * 3 + o, q = (j % n2) * 3 + o;
|
||||
if (sc[p + 2] > 0 && sc[q + 2] > 0 && !e[j % n2]) { g.moveTo(sc[p], sc[p + 1]); g.lineTo(sc[q], sc[q + 1]); }
|
||||
if (sc[p + 2] > 0 && sc[q + 2] > 0 && !e[j % n2]) { g.moveTo(cx + sc[p] * R, cy - sc[p + 1] * R); g.lineTo(cx + sc[q] * R, cy - sc[q + 1] * R); }
|
||||
}
|
||||
o += n2 * 3;
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
/* Generated by scripts/gen-world.mjs from Natural Earth (public domain). */
|
||||
window.URUTAU_WORLD = {"w":2000,"h":789,"paths":{"FJ":"M1990 564l1 -1l2 2l-1 3l-3 0l-4 0l0 -3l2 -2l3 1zM0 556l1 0l-1 2l0 1M1996 560l-3 1l-1 -2l3 -1l2 0l3 -2M0 556z","TZ":"M1188 472l1 1l20 11l1 3l8 6l-3 7l1 3l3 2l0 1l-1 4l0 1l0 3l2 3l2 6l2 1l-4 3l-7 2l-3 0l-2 2l-4 0l-1 1l-7 -2l-4 1l-2 -8l-1 -2l-2 -2l-5 -1l-3 -2l-4 -1l-2 -1l-2 -1l-3 -7l-3 -3l-2 -3l1 -3l-1 -5l2 -1l2 -2l2 -2l2 -2l0 -1l-1 -2l-1 -2l2 -1l0 -3l-2 -3l2 -1l6 0l11 0z","EH":"M952 313l0 2l0 8l-18 0l0 14l-6 0l-1 3l1 8l-22 0l-1 2l0 -2l1 0l12 -1l1 -2l2 -2l2 -8l8 -6l2 -7l2 0l2 -5l4 0l2 0l3 0l2 -1l3 0l0 -3l1 0z","CA":"M318 194l-1 0l-11 -5l-4 -2l-10 -3l-3 -5l1 -3l-7 -2l-1 -5l-7 -4l0 -3l3 -2l0 -4l-10 -3l-5 -7l-4 -4l-5 -2l-4 -3l-3 -2l-5 1l-6 3l-5 -3l-3 -3l-6 -1l-5 0l0 -32l0 -21l10 2l9 2l6 1l5 -2l6 -2l9 1l8 -3l9 -1l4 2l4 -1l1 -3l4 1l9 5l8 -4l1 4l6 -1l2 -1l7 0l9 2l13 2l7 1l6 0l7 3l-8 2l10 2l15 -1l5 -1l6 3l6 -2l-6 -3l4 -2l7 0l4 -1l5 2l5 3l7 -1l9 3l9 -1l8 0l-1 -3l5 -1l9 2l0 5l4 -5l4 1l2 -6l-5 -3l-7 -3l0 -6l7 -4l7 1l6 2l8 7l-5 2l10 2l0 5l7 -4l7 3l-2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1 0l6 -3l6 -1l7 -2l1 -1l-1 -2l-1 -1l3 -1l5 0l5 0l2 -2l1 0l6 -4l2 -1l9 0l10 0l0 -2l2 0l2 -1l2 -2l2 -5l4 -4l2 2l4 -1l2 1l0 8l4 3l1 2l-6 2l-6 2l-6 2l-2 3l-1 2l0 3l1 2l3 1l-1 -2l2 1l-1 1l-3 1l-3 0l-4 1l-3 0l-3 1l-4 1l8 -1l1 1l-7 2l-4 0l0 -1l-2 2l2 0l-1 4l-4 4l-1 -1l-1 0l-2 -2l2 3l1 1l0 2l-2 3l-3 4l1 -4l-3
Line truncated
|
||||
+51
-10
@@ -29,6 +29,45 @@ const ring = (idx) => {
|
||||
return pts;
|
||||
};
|
||||
|
||||
// Rings that cross the antimeridian carry a +-360 degree longitude jump (the source is cut there).
|
||||
// Unwrap them into one continuous ring, then clip against the map band [-180,180] on
|
||||
// copies shifted by -360/0/+360, so each piece is closed along the map border instead of
|
||||
// by a chord across the map.
|
||||
const unwrap = (pts) => {
|
||||
const out = [[pts[0][0], pts[0][1]]];
|
||||
let off = 0;
|
||||
for (let i = 1; i < pts.length; i++) {
|
||||
const d = pts[i][0] + off - out[i - 1][0];
|
||||
if (d > 180) off -= 360; else if (d < -180) off += 360;
|
||||
out.push([pts[i][0] + off, pts[i][1]]);
|
||||
}
|
||||
return out;
|
||||
};
|
||||
// Sutherland-Hodgman against one vertical line
|
||||
const clipX = (pts, edge, keepLeft) => {
|
||||
const inside = (p) => (keepLeft ? p[0] <= edge : p[0] >= edge);
|
||||
const out = [];
|
||||
for (let i = 0; i < pts.length; i++) {
|
||||
const a = pts[i], b = pts[(i + 1) % pts.length];
|
||||
const ia = inside(a), ib = inside(b);
|
||||
if (ia) out.push(a);
|
||||
if (ia !== ib) out.push([edge, a[1] + ((b[1] - a[1]) * (edge - a[0])) / (b[0] - a[0])]);
|
||||
}
|
||||
return out;
|
||||
};
|
||||
const pieces = (pts) => {
|
||||
if (pts.length > 1 && pts[0][0] === pts[pts.length - 1][0] && pts[0][1] === pts[pts.length - 1][1]) pts = pts.slice(0, -1);
|
||||
pts = unwrap(pts);
|
||||
const res = [];
|
||||
for (const k of [-360, 0, 360]) {
|
||||
const shifted = pts.map(([x, y]) => [x + k, y]);
|
||||
if (!shifted.some(([x]) => x > -180 && x < 180)) continue;
|
||||
const c = clipX(clipX(shifted, 180, true), -180, false);
|
||||
if (c.length >= 3) res.push(c);
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
const paths = {}, cent = {};
|
||||
for (const g of topo.objects.countries.geometries) {
|
||||
const c = byNum.get(String(g.id).padStart(3, '0'));
|
||||
@@ -37,17 +76,19 @@ for (const g of topo.objects.countries.geometries) {
|
||||
let d = '';
|
||||
for (const poly of polys) {
|
||||
for (const r of poly) {
|
||||
const pts = ring(r).map(([lo, la]) => [Math.round(px(lo)), Math.round(py(la))]);
|
||||
const out = [];
|
||||
for (const p of pts) { const l = out[out.length - 1]; if (!l || l[0] !== p[0] || l[1] !== p[1]) out.push(p); }
|
||||
if (out.length < 4) continue;
|
||||
let s = `M${out[0][0]} ${out[0][1]}`, px0 = out[0][0], py0 = out[0][1];
|
||||
for (const [x, y] of out.slice(1)) {
|
||||
// a ring crossing the antimeridian jumps across the map: start a new subpath instead of drawing a line over it
|
||||
s += Math.abs(x - px0) > W / 2 ? `M${x} ${y}` : `l${x - px0} ${y - py0}`;
|
||||
px0 = x; py0 = y;
|
||||
for (const piece of pieces(ring(r))) {
|
||||
const out = [];
|
||||
for (const [lo, la] of piece) {
|
||||
const p = [Math.round(px(lo)), Math.round(py(la))];
|
||||
const l = out[out.length - 1];
|
||||
if (!l || l[0] !== p[0] || l[1] !== p[1]) out.push(p);
|
||||
}
|
||||
if (out.length > 1 && out[0][0] === out[out.length - 1][0] && out[0][1] === out[out.length - 1][1]) out.pop();
|
||||
if (out.length < 3) continue;
|
||||
let s = `M${out[0][0]} ${out[0][1]}`, px0 = out[0][0], py0 = out[0][1];
|
||||
for (const [x, y] of out.slice(1)) { s += `l${x - px0} ${y - py0}`; px0 = x; py0 = y; }
|
||||
d += s + 'z';
|
||||
}
|
||||
d += s + 'z';
|
||||
}
|
||||
}
|
||||
if (d) paths[c.cca2] = d;
|
||||
|
||||
Reference in new issue
Block a user