@popcorn245/cornfield 0.52.0 → 0.52.1
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.
|
@@ -65,6 +65,8 @@ export const GREY_ALPHA_TOKEN = '--corn-map-grey-alpha';
|
|
|
65
65
|
export const MIN_GREY_ALPHA = 0.1;
|
|
66
66
|
/** The ink of a node's glyph and of a finer kind's letters (spec 0008 D8); `auto` is the white or the dark that reads on the node's fill (glyphs.js) */
|
|
67
67
|
export const GLYPH_TOKEN = '--corn-map-glyph';
|
|
68
|
+
/** The page's ground under the map (tokens.css; a theme sets its own): what a translucent node's fill is seen over, so what its glyph's ink is chosen against (glyphs.js) */
|
|
69
|
+
export const GROUND_TOKEN = '--corn-ground';
|
|
68
70
|
/** The largest label minimum a theme may ask for: bigger text would leave no room for another label */
|
|
69
71
|
export const MAX_LABEL_MIN = 24;
|
|
70
72
|
/** The width an ordinary line has with no theme (scene.js `flowEdge`): the `--corn-map-edge-width` scales every line by its ratio to this */
|
|
@@ -179,8 +181,9 @@ function greyAlphaOf(value) {
|
|
|
179
181
|
* The tokens as the page computes them.
|
|
180
182
|
* @param {(name: string) => string} read the value of a custom property
|
|
181
183
|
* @param {string[]} [extra] more colour tokens to read: those of the finer kinds and project layers on the map (`setMapSubjects`)
|
|
182
|
-
* @returns {{values: Record<string, string>, strokeWidth: number, font: string | null, edgeWidth: number | null, glow: number | null, labelMin: number | null, greyAlpha: number | null}}
|
|
183
|
-
* `values` holds only the tokens that are a colour (not `auto`); `font`, `edgeWidth`, `glow`, `labelMin` and `greyAlpha` are null at `auto` or when the value is not one
|
|
184
|
+
* @returns {{values: Record<string, string>, strokeWidth: number, font: string | null, edgeWidth: number | null, glow: number | null, labelMin: number | null, greyAlpha: number | null, ground: string | null}}
|
|
185
|
+
* `values` holds only the tokens that are a colour (not `auto`); `font`, `edgeWidth`, `glow`, `labelMin` and `greyAlpha` are null at `auto` or when the value is not one;
|
|
186
|
+
* `ground` is the page's ground (`--corn-ground`) as a colour, or null when it is not one
|
|
184
187
|
*/
|
|
185
188
|
export function readMapTokens(read, extra = []) {
|
|
186
189
|
const values = {};
|
|
@@ -197,6 +200,7 @@ export function readMapTokens(read, extra = []) {
|
|
|
197
200
|
glow: factorOf(read(GLOW_TOKEN)),
|
|
198
201
|
labelMin: labelMinOf(read(LABEL_MIN_TOKEN)),
|
|
199
202
|
greyAlpha: greyAlphaOf(read(GREY_ALPHA_TOKEN)),
|
|
203
|
+
ground: cssColor(read(GROUND_TOKEN)),
|
|
200
204
|
};
|
|
201
205
|
}
|
|
202
206
|
|
|
@@ -261,14 +265,16 @@ export function createIconStore(urls, { load = loadImage, onChange = () => {}, w
|
|
|
261
265
|
* @property {number | null} glow the glow factor (`--corn-map-glow`), null at `auto`
|
|
262
266
|
* @property {number | null} labelMin the smallest label size in px (`--corn-map-label-min`), null at `auto` or under 9px
|
|
263
267
|
* @property {number | null} greyAlpha how much of a greyed node is left (`--corn-map-grey-alpha`), null at `auto` or when it is not a number from 0.1 to 1
|
|
268
|
+
* @property {string | null} ground the page's ground (`--corn-ground`), null when it is not a colour: a translucent node is seen over it (glyphs.js). It sets nothing
|
|
269
|
+
* in the picture, so it does not make a style less plain
|
|
264
270
|
* @property {ReturnType<typeof createIconStore> | null} icons
|
|
265
271
|
* @property {boolean} pixelated sample icons without smoothing
|
|
266
272
|
* @property {boolean} plain nothing to apply: no colour set, no icon loaded (the scene is drawn as it is)
|
|
267
273
|
*/
|
|
268
274
|
|
|
269
|
-
const NO_TOKENS = { values: {}, strokeWidth: DEFAULT_STROKE_WIDTH, font: null, edgeWidth: null, glow: null, labelMin: null, greyAlpha: null };
|
|
275
|
+
const NO_TOKENS = { values: {}, strokeWidth: DEFAULT_STROKE_WIDTH, font: null, edgeWidth: null, glow: null, labelMin: null, greyAlpha: null, ground: null };
|
|
270
276
|
/** The style with nothing set: what a renderer or a label layer made without an instance draws with (the scene as it is) */
|
|
271
|
-
export const PLAIN_STYLE = Object.freeze({ version: 0, values: Object.freeze({}), strokeWidth: DEFAULT_STROKE_WIDTH, font: null, edgeWidth: null, glow: null, labelMin: null, greyAlpha: null, icons: null, pixelated: false, plain: true });
|
|
277
|
+
export const PLAIN_STYLE = Object.freeze({ version: 0, values: Object.freeze({}), strokeWidth: DEFAULT_STROKE_WIDTH, font: null, edgeWidth: null, glow: null, labelMin: null, greyAlpha: null, ground: null, icons: null, pixelated: false, plain: true });
|
|
272
278
|
const MAX_SUBJECT_TOKENS = 500;
|
|
273
279
|
|
|
274
280
|
/**
|
|
@@ -287,7 +293,7 @@ export function createMapStyle(inst) {
|
|
|
287
293
|
|
|
288
294
|
const compose = () => {
|
|
289
295
|
const plain = !Object.keys(tokens.values).length && !(icons && icons.anyReady()) && tokens.font === null && tokens.edgeWidth === null && tokens.glow === null && tokens.labelMin === null && tokens.greyAlpha === null;
|
|
290
|
-
return Object.freeze({ version, values: tokens.values, strokeWidth: tokens.strokeWidth, font: tokens.font, edgeWidth: tokens.edgeWidth, glow: tokens.glow, labelMin: tokens.labelMin, greyAlpha: tokens.greyAlpha, icons, pixelated, plain });
|
|
296
|
+
return Object.freeze({ version, values: tokens.values, strokeWidth: tokens.strokeWidth, font: tokens.font, edgeWidth: tokens.edgeWidth, glow: tokens.glow, labelMin: tokens.labelMin, greyAlpha: tokens.greyAlpha, ground: tokens.ground, icons, pixelated, plain });
|
|
291
297
|
};
|
|
292
298
|
let current = compose();
|
|
293
299
|
|
|
@@ -330,7 +336,7 @@ export function createMapStyle(inst) {
|
|
|
330
336
|
refresh(read = inst.tokenReader()) {
|
|
331
337
|
if (!read) return false;
|
|
332
338
|
const next = readMapTokens(read, subjectTokens);
|
|
333
|
-
const same = next.strokeWidth === tokens.strokeWidth && next.font === tokens.font && next.edgeWidth === tokens.edgeWidth && next.glow === tokens.glow && next.labelMin === tokens.labelMin
|
|
339
|
+
const same = next.strokeWidth === tokens.strokeWidth && next.font === tokens.font && next.edgeWidth === tokens.edgeWidth && next.glow === tokens.glow && next.labelMin === tokens.labelMin && next.ground === tokens.ground
|
|
334
340
|
&& Object.keys(next.values).length === Object.keys(tokens.values).length
|
|
335
341
|
&& Object.entries(next.values).every(([k, v]) => tokens.values[k] === v);
|
|
336
342
|
if (same) return false;
|
package/explorer/glyphs.js
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { NODE_THEMES } from '../core/schema.js';
|
|
16
|
-
import { parseColor } from './theme-model.js';
|
|
16
|
+
import { DARK_GROUND, LIGHT_GROUND, parseColor } from './theme-model.js';
|
|
17
|
+
import { over } from '../core/color.js';
|
|
17
18
|
|
|
18
19
|
/** A node is at least this many px across (on screen) before its glyph is drawn: smaller, no glyph reads and the silhouette does the work */
|
|
19
20
|
export const GLYPH_MIN_PX = 14;
|
|
@@ -48,14 +49,21 @@ const luminanceOf = ([r, g, b]) => {
|
|
|
48
49
|
};
|
|
49
50
|
const ratioOf = (a, b) => { const [hi, lo] = a > b ? [a, b] : [b, a]; return (hi + 0.05) / (lo + 0.05); };
|
|
50
51
|
|
|
51
|
-
/** The ink that reads on a fill: white or dark, whichever has the higher contrast (the glyph is at least 3:1 on every fill of the default palette: a test holds it) */
|
|
52
|
-
export function inkFor(fill) {
|
|
53
|
-
|
|
52
|
+
/** The ink that reads on a fill (seen over `ground`, when the fill is translucent): white or dark, whichever has the higher contrast (the glyph is at least 3:1 on every fill of the default palette: a test holds it) */
|
|
53
|
+
export function inkFor(fill, ground = DARK_GROUND) {
|
|
54
|
+
let rgba = parseColor(fill);
|
|
55
|
+
// A translucent fill is seen over the map's ground (a node is drawn translucent, renderer-canvas2d.js), so the ink is chosen against that.
|
|
56
|
+
// The ground is opaque: a translucent one is taken over black, as a canvas with nothing under it shows
|
|
57
|
+
if (rgba[3] < 1) rgba = over(rgba, over(parseColor(ground), [0, 0, 0, 1]));
|
|
58
|
+
const lum = luminanceOf(rgba);
|
|
54
59
|
return ratioOf(1, lum) >= ratioOf(luminanceOf(parseColor(INK_DARK)), lum) ? INK_LIGHT : INK_DARK;
|
|
55
60
|
}
|
|
56
61
|
|
|
57
|
-
/** The
|
|
58
|
-
|
|
62
|
+
/** The ground a node is seen over: the theme's (`--corn-ground`, the style's `ground`), else the light or the dark one */
|
|
63
|
+
const groundOf = (style, theme) => (style && style.ground) || (theme === 'light' ? LIGHT_GROUND : DARK_GROUND);
|
|
64
|
+
|
|
65
|
+
/** The ink a node's glyph is drawn in: the theme's (`--corn-map-glyph`, in the style's `values`), else the one that reads on its fill (over the ground, when it is translucent) */
|
|
66
|
+
export const glyphInk = (node, style, theme = 'dark') => (style && style.values && style.values['--corn-map-glyph']) || inkFor(node.color, groundOf(style, theme));
|
|
59
67
|
|
|
60
68
|
/** Whether a node's glyph is drawn at this zoom: it has one, no icon or letters replace it, and it is wide enough on screen */
|
|
61
69
|
export const showsGlyph = (node, zoom) => !!node.glyph && !node.icon && !node.letters && node.r * 2 * zoom >= GLYPH_MIN_PX;
|
|
@@ -28,7 +28,7 @@ import { kindLetters } from '../../core/layers.js';
|
|
|
28
28
|
import { reviewHides, rowKeyOf, shownByProposal } from '../layer-model.js';
|
|
29
29
|
import { layerShows } from '../scene.js';
|
|
30
30
|
import { STROKE_TOKEN, kindToken, mapStyleOf } from '../engine/map-style.js';
|
|
31
|
-
import { over, parseColor, contrast } from '../../core/color.js';
|
|
31
|
+
import { over, parseColor, contrast, toHex } from '../../core/color.js';
|
|
32
32
|
import { DARK_GROUND, LIGHT_GROUND } from '../theme-model.js';
|
|
33
33
|
import { t } from '../engine/strings.js';
|
|
34
34
|
import { renderFlowLegend } from '../engine/flow-legend.js';
|
|
@@ -128,9 +128,9 @@ export function mount(root, inst, options = {}) {
|
|
|
128
128
|
const [r, g, b] = over(surface, over(ground, [0, 0, 0, 1]));
|
|
129
129
|
return `rgb(${r}, ${g}, ${b})`;
|
|
130
130
|
}
|
|
131
|
-
/** The outline a dot or swatch gets when its fill is under 3:1 on the menu: the map's own outline colour when the theme sets one, else the CSS default (`.is-ringed`). The fill is never changed */
|
|
131
|
+
/** The outline a dot or swatch gets when its fill (as it shows over the menu) is under 3:1 on the menu: the map's own outline colour when the theme sets one, else the CSS default (`.is-ringed`). The fill is never changed */
|
|
132
132
|
function ringOf(color, surface) {
|
|
133
|
-
if (contrast(color, surface) >= 3) return null;
|
|
133
|
+
if (contrast(toHex(over(parseColor(color), parseColor(surface))), surface) >= 3) return null; // a translucent fill is seen over the menu, as the node is over the ground
|
|
134
134
|
const stroke = style().values[STROKE_TOKEN];
|
|
135
135
|
return { stroke: stroke ? swatch(stroke) : '' };
|
|
136
136
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* labels are the label layer's (labels.js), one transparent canvas over the map for either renderer.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { CORE_RATIO, ARROW, END_SHAPES, SHAPE_SIZES, EDGE_STRIKE, MARK_MIN_PX, edgePoint, looksFor, packetPoint } from './scene.js';
|
|
11
|
+
import { CORE_RATIO, ARROW, END_SHAPES, SHAPE_REACH, SHAPE_SIZES, EDGE_STRIKE, MARK_MIN_PX, edgePoint, looksFor, packetPoint, parseColor } from './scene.js';
|
|
12
12
|
import { GLYPH_TOKEN, ICON_RATIO, PLAIN_STYLE, looksWith, styledScene } from './engine/map-style.js';
|
|
13
13
|
import { LETTER_RATIO, letterImage, showsLetters } from './kind-letters.js';
|
|
14
14
|
import { GLYPH_RATIO, glyphImage, glyphInk, showsGlyph } from './glyphs.js';
|
|
@@ -18,6 +18,17 @@ const TAU = Math.PI * 2;
|
|
|
18
18
|
const GLOW_MIN_PX = 1.5;
|
|
19
19
|
/** A scene with this many edges or fewer is drawn directly each frame; more, and its lines go into the layer while packets move */
|
|
20
20
|
export const LAYER_MIN_EDGES = 600;
|
|
21
|
+
const alphas = new Map();
|
|
22
|
+
/** The alpha of a node's colour (0..1; 1 for what is not read), remembered: it is asked for every glowing node of every frame */
|
|
23
|
+
function alphaOf(color) {
|
|
24
|
+
let a = alphas.get(color);
|
|
25
|
+
if (a === undefined) {
|
|
26
|
+
if (alphas.size > 512) alphas.clear();
|
|
27
|
+
a = parseColor(color)[3];
|
|
28
|
+
alphas.set(color, a);
|
|
29
|
+
}
|
|
30
|
+
return a;
|
|
31
|
+
}
|
|
21
32
|
const circle = (ctx, x, y, r) => { ctx.beginPath(); ctx.arc(x, y, r, 0, TAU); };
|
|
22
33
|
|
|
23
34
|
/**
|
|
@@ -25,29 +36,30 @@ const circle = (ctx, x, y, r) => { ctx.beginPath(); ctx.arc(x, y, r, 0, TAU); };
|
|
|
25
36
|
* a rounded square for data, a hexagon for what is outside, a square for where things run, a diamond for people. The WebGL node shader draws the same shapes
|
|
26
37
|
* with the same sizes (scene.js `SHAPE_SIZES`, shaders.js `sdShape`).
|
|
27
38
|
*/
|
|
28
|
-
export function silhouette(ctx, shape, x, y, r) {
|
|
39
|
+
export function silhouette(ctx, shape, x, y, r, add = false) {
|
|
40
|
+
const begin = () => { if (!add) ctx.beginPath(); }; // `add`: another piece of the path being built (a clip with a hole), not a new path
|
|
29
41
|
if (shape === 'rounded-square' || shape === 'square') {
|
|
30
42
|
const h = r * (shape === 'square' ? SHAPE_SIZES.squareHalf : SHAPE_SIZES.roundedHalf);
|
|
31
43
|
const c = r * (shape === 'square' ? SHAPE_SIZES.squareCorner : SHAPE_SIZES.roundedCorner);
|
|
32
|
-
|
|
44
|
+
begin();
|
|
33
45
|
if (ctx.roundRect) ctx.roundRect(x - h, y - h, h * 2, h * 2, c); else ctx.rect(x - h, y - h, h * 2, h * 2);
|
|
34
46
|
return;
|
|
35
47
|
}
|
|
36
48
|
if (shape === 'hexagon') {
|
|
37
49
|
const R = (r * SHAPE_SIZES.hexInradius) / Math.cos(Math.PI / 6); // flat top and bottom: the inradius is what the SDF takes
|
|
38
|
-
|
|
50
|
+
begin();
|
|
39
51
|
for (let i = 0; i < 6; i++) { const a = Math.PI / 6 + (i * Math.PI) / 3; const px = x + R * Math.cos(a), py = y + R * Math.sin(a); if (i) ctx.lineTo(px, py); else ctx.moveTo(px, py); }
|
|
40
52
|
ctx.closePath();
|
|
41
53
|
return;
|
|
42
54
|
}
|
|
43
55
|
if (shape === 'diamond') {
|
|
44
56
|
const h = r * SHAPE_SIZES.diamondHalf;
|
|
45
|
-
|
|
57
|
+
begin();
|
|
46
58
|
ctx.moveTo(x, y - h); ctx.lineTo(x + h, y); ctx.lineTo(x, y + h); ctx.lineTo(x - h, y);
|
|
47
59
|
ctx.closePath();
|
|
48
60
|
return;
|
|
49
61
|
}
|
|
50
|
-
circle(ctx, x, y, r);
|
|
62
|
+
if (add) { ctx.moveTo(x + r, y); ctx.arc(x, y, r, 0, TAU); } else circle(ctx, x, y, r);
|
|
51
63
|
}
|
|
52
64
|
|
|
53
65
|
// ---------------------------------------------------------------------------
|
|
@@ -276,7 +288,7 @@ function edgesInView(scene, camera, width, height) {
|
|
|
276
288
|
// ---------------------------------------------------------------------------
|
|
277
289
|
// Nodes
|
|
278
290
|
// ---------------------------------------------------------------------------
|
|
279
|
-
function drawNode(ctx, node, zoom, looks, style) {
|
|
291
|
+
function drawNode(ctx, node, zoom, looks, style, theme) {
|
|
280
292
|
ctx.save();
|
|
281
293
|
ctx.globalAlpha = node.alpha;
|
|
282
294
|
|
|
@@ -319,9 +331,31 @@ function drawNode(ctx, node, zoom, looks, style) {
|
|
|
319
331
|
// A soft disc behind the node, not `shadowBlur` (see drawEdge): one cheap fill instead of a blur pass
|
|
320
332
|
ctx.save();
|
|
321
333
|
ctx.globalAlpha = node.alpha * 0.28;
|
|
322
|
-
|
|
334
|
+
const reach = node.r + node.glow * 0.7;
|
|
323
335
|
ctx.fillStyle = node.color;
|
|
324
|
-
|
|
336
|
+
if (alphaOf(node.color) < 1) {
|
|
337
|
+
// Under a translucent fill the glow is left out, so the fill alone sets what shows through it; WebGL's node shader does the same.
|
|
338
|
+
// The shape inside the glow's disc (the usual case): the disc with the shape as a hole, filled even-odd. A square's corners or a diamond's
|
|
339
|
+
// points can reach past a small glow's disc (a theme's --corn-map-glow), and that fill would put them over the glow: then the disc is
|
|
340
|
+
// clipped to everything but the shape (a square round both, the shape cut out even-odd)
|
|
341
|
+
if (node.r * (SHAPE_REACH[node.shape] || 1) < reach) {
|
|
342
|
+
circle(ctx, node.x, node.y, reach);
|
|
343
|
+
silhouette(ctx, node.shape, node.x, node.y, node.r, true);
|
|
344
|
+
ctx.fill('evenodd');
|
|
345
|
+
} else {
|
|
346
|
+
const side = reach + node.r;
|
|
347
|
+
ctx.beginPath();
|
|
348
|
+
ctx.rect(node.x - side, node.y - side, side * 2, side * 2);
|
|
349
|
+
silhouette(ctx, node.shape, node.x, node.y, node.r, true);
|
|
350
|
+
ctx.clip('evenodd');
|
|
351
|
+
circle(ctx, node.x, node.y, reach);
|
|
352
|
+
ctx.fill();
|
|
353
|
+
}
|
|
354
|
+
} else {
|
|
355
|
+
// An opaque fill hides the glow under it: drawn as it always was
|
|
356
|
+
circle(ctx, node.x, node.y, reach);
|
|
357
|
+
ctx.fill();
|
|
358
|
+
}
|
|
325
359
|
ctx.restore();
|
|
326
360
|
silhouette(ctx, node.shape, node.x, node.y, node.r);
|
|
327
361
|
}
|
|
@@ -331,7 +365,7 @@ function drawNode(ctx, node, zoom, looks, style) {
|
|
|
331
365
|
// The glyph takes the core dot's place: drawn over it, the dot would fill the glyph's own shapes and blur it at the sizes nodes have
|
|
332
366
|
const image = node.icon && style.icons ? style.icons.get(node.icon) : null;
|
|
333
367
|
const letters = !image && showsLetters(node, zoom);
|
|
334
|
-
const glyph = !image && !letters && showsGlyph(node, zoom) ? glyphImage(node.glyph, glyphInk(node, style)) : null;
|
|
368
|
+
const glyph = !image && !letters && showsGlyph(node, zoom) ? glyphImage(node.glyph, glyphInk(node, style, theme)) : null;
|
|
335
369
|
if (!glyph) {
|
|
336
370
|
circle(ctx, node.x, node.y, node.r * CORE_RATIO);
|
|
337
371
|
ctx.fillStyle = looks.core;
|
|
@@ -460,7 +494,7 @@ export function createCanvas2dRenderer(canvas, opts = {}) {
|
|
|
460
494
|
ctx.translate(camera.x, camera.y);
|
|
461
495
|
ctx.scale(camera.zoom, camera.zoom);
|
|
462
496
|
inView.forEach((edge) => { if (edge.packet) drawPacket(ctx, edge, timeMs, camera.zoom); });
|
|
463
|
-
scene.nodes.forEach((node) => drawNode(ctx, node, camera.zoom, looks, style));
|
|
497
|
+
scene.nodes.forEach((node) => drawNode(ctx, node, camera.zoom, looks, style, scene.theme));
|
|
464
498
|
ctx.restore();
|
|
465
499
|
return;
|
|
466
500
|
}
|
|
@@ -475,7 +509,7 @@ export function createCanvas2dRenderer(canvas, opts = {}) {
|
|
|
475
509
|
if (decor.rings.length) drawRings(ctx, decor.rings);
|
|
476
510
|
|
|
477
511
|
inView.forEach((edge) => drawEdge(ctx, edge, timeMs, camera.zoom));
|
|
478
|
-
scene.nodes.forEach((node) => drawNode(ctx, node, camera.zoom, looks, style));
|
|
512
|
+
scene.nodes.forEach((node) => drawNode(ctx, node, camera.zoom, looks, style, scene.theme));
|
|
479
513
|
// No text here: every label (and the strike through a removed one) is drawn by the label layer (labels.js) over this canvas
|
|
480
514
|
|
|
481
515
|
ctx.restore();
|
|
@@ -226,7 +226,7 @@ export function packIcons(scene, has, style = null) {
|
|
|
226
226
|
let kind = n.icon && has(n.icon) ? n.icon : null;
|
|
227
227
|
let side = n.r * ICON_RATIO;
|
|
228
228
|
if (!kind && !n.icon && n.letters && has(letterKey(n.letters))) { kind = letterKey(n.letters); side = n.r * LETTER_RATIO; }
|
|
229
|
-
if (!kind && !n.icon && !n.letters && n.glyph) { const key = glyphKey(n.glyph, glyphInk(n, style)); if (has(key)) { kind = key; side = n.r * GLYPH_RATIO; } } // the type's own glyph, last (glyphs.js)
|
|
229
|
+
if (!kind && !n.icon && !n.letters && n.glyph) { const key = glyphKey(n.glyph, glyphInk(n, style, scene.theme)); if (has(key)) { kind = key; side = n.r * GLYPH_RATIO; } } // the type's own glyph, last (glyphs.js)
|
|
230
230
|
if (!kind) return;
|
|
231
231
|
if (!byKind.has(kind)) byKind.set(kind, { rows: [], minR: Infinity, maxR: 0 });
|
|
232
232
|
const group = byKind.get(kind);
|
|
@@ -458,6 +458,7 @@ export function createWebglRenderer(canvas, opts = {}) {
|
|
|
458
458
|
let packed = null;
|
|
459
459
|
let packedScene = null;
|
|
460
460
|
let packedVersion;
|
|
461
|
+
let packedGround = null; // the ground the icon rows were packed for: a translucent node's glyph ink depends on it (glyphs.js)
|
|
461
462
|
let lastArgs = null;
|
|
462
463
|
|
|
463
464
|
/** A pass only a theme asks for (EXTRA_PASSES), built the first time it is wanted */
|
|
@@ -527,6 +528,7 @@ export function createWebglRenderer(canvas, opts = {}) {
|
|
|
527
528
|
gpu.glyphInk = ink;
|
|
528
529
|
packedScene = null; // the icon rows are made again for the new ink
|
|
529
530
|
}
|
|
531
|
+
if (packedGround !== style.ground) { packedGround = style.ground; packedScene = null; } // another ground: a translucent node's glyph may take the other ink
|
|
530
532
|
if (scene !== packedScene || scene.version !== packedVersion) {
|
|
531
533
|
packed = { ...packScene(scene), strokes: packStrokes(scene), icons: packIcons(scene, (kind) => (isLetterKey(kind) ? !!letterImage(lettersOfKey(kind), ink) : isGlyphKey(kind) ? !!glyphImage(glyphOfKey(kind).type, glyphOfKey(kind).ink) : !!(style.icons && style.icons.get(kind))), style) };
|
|
532
534
|
packedScene = scene;
|
package/explorer/shaders.js
CHANGED
|
@@ -289,15 +289,26 @@ void main() {
|
|
|
289
289
|
over(acc, ring.rgb, ring.a * al * coverBand(abs(len - (rw + u_haloGeom[halo].y) * zoom), u_haloGeom[halo].z * zoom * 0.5, pix));
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
// Glow: a blurred copy of the disc under it (see glowDisc)
|
|
293
|
-
float glow = v_color.w;
|
|
294
|
-
if (glow > 0.0) over(acc, v_color.rgb, v_kind.z * al * glowDisc(len, R, glow * 0.5 / u_dpr));
|
|
295
|
-
|
|
296
|
-
// The silhouette, and its white core unless the type's glyph is drawn there (glyphs.js: the icon pass draws it once the node is wide enough)
|
|
297
292
|
int shapeCode = int(v_kind.w + 0.5);
|
|
298
293
|
bool glyph = shapeCode >= 8;
|
|
299
294
|
if (glyph) shapeCode -= 8;
|
|
300
|
-
|
|
295
|
+
float shapeCover = coverEdge(sdShape(v_local, R, shapeCode, len), pix); // how much of this pixel the silhouette covers
|
|
296
|
+
|
|
297
|
+
// Glow: a blurred copy of the disc under it (see glowDisc), then the silhouette. An opaque fill hides the glow under it: drawn as it always was.
|
|
298
|
+
// Under a translucent fill the glow is left out, so the fill alone sets what is seen through it, as renderer-canvas2d.js drawNode does (a clip).
|
|
299
|
+
// Glow and fill are the same colour, so that is ONE layer: the fill in the part of the pixel the silhouette covers, the glow in the rest. Two
|
|
300
|
+
// layers (the glow times 1 - cover, then the fill times cover) would let the ground through both at the edge: a dark line round a square or a
|
|
301
|
+
// diamond, whose sides lie inside the glow's disc
|
|
302
|
+
float glow = v_color.w;
|
|
303
|
+
if (v_kind.z < 1.0) {
|
|
304
|
+
float soft = glow > 0.0 ? glowDisc(len, R, glow * 0.5 / u_dpr) : 0.0;
|
|
305
|
+
over(acc, v_color.rgb, v_kind.z * al * mix(soft, 1.0, shapeCover));
|
|
306
|
+
} else {
|
|
307
|
+
if (glow > 0.0) over(acc, v_color.rgb, v_kind.z * al * glowDisc(len, R, glow * 0.5 / u_dpr));
|
|
308
|
+
over(acc, v_color.rgb, v_kind.z * al * shapeCover);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// The white core unless the type's glyph is drawn there (glyphs.js: the icon pass draws it once the node is wide enough)
|
|
301
312
|
if (!glyph || 2.0 * R < u_glyphMin) over(acc, u_core.rgb, u_core.a * al * coverEdge(len - R * u_coreRatio, pix));
|
|
302
313
|
|
|
303
314
|
// Mark: a ring with the look of its own mark (dashed when its dash is set: added), and for removed a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@popcorn245/cornfield",
|
|
3
|
-
"version": "0.52.
|
|
3
|
+
"version": "0.52.1",
|
|
4
4
|
"description": "A self-hostable dev dashboard with the topology map at its centre: proposals on the map, scenarios, outages and what-if edits, for any repo.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "popcorn245 (https://github.com/popcorn245)",
|