Skip to content

World's first open-source enterprise world model.

A node's name sits on a chip (#605)

WaylandYang893dbeb99060
diff --git a/web/src/pages/graphCanvas.ts b/web/src/pages/graphCanvas.ts
index f2390b24..06a76d43 100644
--- a/web/src/pages/graphCanvas.ts
+++ b/web/src/pages/graphCanvas.ts
@@ -179,7 +179,7 @@ export function softMutedNode(
}
/** 指着的那一个:×1.08,最小 10.4,偏白的环——为的是跳出来。
- * 名字出一块**深底浅字**的底牌,与选中那一档同一副形状(选中是反过来的
+ * 名字那块牌子的底亮一档并浮起来,与选中那一档同一副形状(选中是反色的
* 浅底深字)。从前这里是一张浮起来的两行卡片,与选中完全不像 */
export function hoveredNode(
res: NodeAttrs,
@@ -189,7 +189,7 @@ export function hoveredNode(
res.size = Math.max(base * 1.08, 10.4);
res.ringColor = mix(ownColorOf(attrs), INK, RING_HOVER_MIX);
res.forceLabel = true;
- res.labelSlab = true;
+ res.labelLift = true;
res.zIndex = 4;
return deferToHoverLayer(res);
}
@@ -222,8 +222,8 @@ export function selectedNode(
res.size = Math.max(base * 1.02, 9.2);
res.ringColor = mix(ownColorOf(attrs), INK, RING_SELECT_MIX);
res.forceLabel = true;
- res.labelSlab = true;
- // **反色**:浅底深字。指到的那一个是深底浅字,同一副形状调个个儿——
+ res.labelLift = true;
+ // **反色**:浅底深字。指到的那一个是底亮一档的牌子,同一副形状调个个儿——
// 一眼分得出"我正指着"和"我选中了",而不必再多一种记号
res.labelInvert = true;
// 再加粗一档。反色要看向它才读得出来,字重在余光里也分得清
diff --git a/web/src/pages/graphVisuals.ts b/web/src/pages/graphVisuals.ts
index 24d8dc54..0216c2ee 100644
--- a/web/src/pages/graphVisuals.ts
+++ b/web/src/pages/graphVisuals.ts
@@ -29,6 +29,10 @@ export let MUTED_SHELL = "#151515";
每划过一个节点就换一次,压到底会让整张画布不停明灭 */
export const HOVER_MUTE = 0.78;
export let PILL_BG = "rgba(12,12,12,0.9)";
+/** 指到的那一块底。静止那档是 `PILL_BG`,选中那档反色,见 `drawNodeLabel` */
+export let PILL_BG_HOVER = "rgba(42,42,42,0.96)";
+/** 选中那一档的底(反色)。**不等于 `PILL_TEXT`**:纸底上的墨是近黑的 */
+export let PILL_INVERT = "#ededed";
export let PILL_BORDER = "rgba(255,255,255,0.14)"; // --u-line-strong
export let PILL_TEXT = "#ededed"; // --u-text
/* 裸字的光晕:与画布同色(--u-ground)的一圈描边,只为把从字底下穿过的
@@ -132,26 +136,35 @@ export function drawNodeLabel(
const x = data.x + dx + w + padX > vw ? data.x - dx - w : data.x + dx;
const y = data.y - dy - size / 2 < 0 ? data.y + dy : data.y - dy;
ctx.save();
- if (data.labelSlab) {
- /* 一块底,圆角 cell(4)、无描边——底已经把它托起来了。
- **两档**:指到的是深底浅字,选中的反过来,浅底深字。同一副形状、同一个
- 位置,只有明暗调个个儿——"指着"与"选中"是同一件事的两个程度,从前一个是
- 浮起来的两行卡片、一个是这块底牌,看着像两种不同的东西 */
- const h = size + padY * 2;
+ /* **名字总是一块牌子**:一块底 + 一圈细边,圆角 cell(4)。三档只换颜色,
+ 形状与位置一动不动——
+ 静止 `--u-pill-bg` + `--u-line-strong` 的边
+ 指到的 `--u-pill-bg-hover`,底亮一档,并浮起来(投影)
+ 选中的 反色(浅底深字),加粗一档,也浮起来
+ 从前静止那档是裸字加一圈画布色描边,只有指到/选中的才有底。裸字在一片
+ 连线和节点之间读起来费劲——描边压住的是线,压不住线背后深浅不一的底,
+ 而一块牌子自带一个稳定的底。代价是画面更满,所以牌子的边只有一档细线、
+ 静止那档不带投影:一屏几十块牌子,每块都浮着就糊成一片。 */
+ const h = size + padY * 2;
+ if (data.labelLift) {
ctx.shadowColor = token("--u-shadow", "rgba(0,0,0,0.6)");
ctx.shadowBlur = 12;
- ctx.beginPath();
- ctx.roundRect(x - padX, y - h / 2, w + padX * 2, h, 4);
- ctx.fillStyle = data.labelInvert ? PILL_TEXT : PILL_BG;
- ctx.fill();
- ctx.shadowBlur = 0;
- } else {
- /* 裸字:先描一圈画布色再填字(canvas 版的 paint-order: stroke fill),
- 连线从字底下穿过时不至于糊在一起 */
- ctx.lineWidth = 3.5;
- ctx.lineJoin = "round";
- ctx.strokeStyle = LABEL_HALO;
- ctx.strokeText(data.label, x, y);
+ }
+ ctx.beginPath();
+ ctx.roundRect(x - padX, y - h / 2, w + padX * 2, h, 4);
+ ctx.fillStyle = data.labelInvert
+ ? PILL_INVERT
+ : data.labelLift
+ ? PILL_BG_HOVER
+ : PILL_BG;
+ ctx.fill();
+ // 投影只跟着底走:描边再来一次会把那圈黑描重一倍
+ ctx.shadowBlur = 0;
+ /* 反色那一档不描边:浅底自己就与画布分得开,再描一圈看着像两层皮 */
+ if (!data.labelInvert) {
+ ctx.lineWidth = 1;
+ ctx.strokeStyle = PILL_BORDER;
+ ctx.stroke();
}
ctx.fillStyle = data.labelInvert ? LABEL_HALO : PILL_TEXT;
ctx.fillText(data.label, x, y);
@@ -314,6 +327,8 @@ export function refreshPalette() {
NODE_BORDER_BASE = token("--u-node-border", NODE_BORDER_BASE);
MUTED_SHELL = token("--u-node-muted", MUTED_SHELL);
PILL_BG = token("--u-pill-bg", PILL_BG);
+ PILL_BG_HOVER = token("--u-pill-bg-hover", PILL_BG_HOVER);
+ PILL_INVERT = token("--u-pill-invert", PILL_INVERT);
PILL_BORDER = token("--u-line-strong", PILL_BORDER);
PILL_TEXT = token("--u-text", PILL_TEXT);
LABEL_HALO = token("--u-halo", LABEL_HALO);
diff --git a/web/src/styles.css b/web/src/styles.css
index 229463d7..1580504a 100644
--- a/web/src/styles.css
+++ b/web/src/styles.css
@@ -173,6 +173,12 @@
--u-edge-relation-focus: rgba(var(--u-ink-rgb), 0.6);
--u-edge-schema-dim: rgba(48, 48, 48, 0.4);
--u-pill-bg: rgba(12, 12, 12, 0.9);
+ /* 指到的那块名字牌。暗底上往亮里走一档——与 chrome 里 hover 升一层面
+ (surface → surface-2)是同一个说法,只是画布上的面必须够实,
+ 底下压着的是线和点,不是页面的底 */
+ --u-pill-bg-hover: rgba(42, 42, 42, 0.96);
+ /* 选中的那块名字牌:底浅字深,反着来。暗底上它就是墨色本身 */
+ --u-pill-invert: var(--u-text);
--u-halo: rgba(var(--u-ground-rgb), 0.92);
/* 时间轴刻度:走过的、播放头、没到的 */
--u-scrub-past: rgba(var(--u-ink-rgb), 0.32);
@@ -256,6 +262,12 @@
--u-edge-relation-focus: rgba(23, 23, 23, 0.85);
--u-edge-schema-dim: rgba(23, 23, 23, 0.12);
--u-pill-bg: rgba(255, 255, 255, 0.92);
+ /* 纸底上反过来:hover 往暗里走一档(chrome 的 --u-surface 也是加黑) */
+ --u-pill-bg-hover: rgba(236, 236, 236, 0.96);
+ /* 反色那一档**不跟着墨色走**:纸底上的墨是 #171717,一块纯黑的牌子压在
+ 一张浅色的图上,比暗底上那块近白的牌子重得多——同样是"反过来",
+ 在纸上要收一档。深灰仍然与指到的那块浅灰分得清清楚楚 */
+ --u-pill-invert: #3f3f3f;
--u-shadow: rgba(0, 0, 0, 0.18);
--u-ok-rgb: 26, 127, 75;
--u-warn-rgb: 154, 106, 18;