Skip to content

👾 Open Computer Use – Open-Source Alternative to Codex Computer Use

Refine StandaloneCursorLab synthesized cursor style

Leoc56b045545d4
diff --git a/Package.swift b/Package.swift
index 12cc295..eeef4c6 100644
--- a/Package.swift
+++ b/Package.swift
@@ -55,10 +55,7 @@ let package = Package(
),
.executableTarget(
name: "StandaloneCursorLab",
- path: "experiments/StandaloneCursorLab/Sources/StandaloneCursorLab",
- resources: [
- .process("Resources"),
- ]
+ path: "experiments/StandaloneCursorLab/Sources/StandaloneCursorLab"
),
.target(
name: "StandaloneCursorSupport",
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
index 920e0c3..736ed17 100644
--- a/docs/ARCHITECTURE.md
+++ b/docs/ARCHITECTURE.md
@@ -84,7 +84,8 @@
- 这条线优先验证 Python 重建脚本已经收敛出来的核心:`20` 条候选路径、`measure + score`、`prefer in-bounds then lowest-score` 选路,以及 `response=1.4` / `dampingFraction=0.9` / `dt=1/240` 的 raw spring timeline。
- 当前它刻意不引入 speculative 的 wall-clock duration 映射,也不复用 `StandaloneCursorLab` 里更偏视觉手感试验的 pose dynamics。
- `StandaloneCursorLab` 是一个单独的 SwiftUI demo target,可通过 `swift run StandaloneCursorLab` 本地启动。
-- 这条线优先验证 motion model 本身:当前主线是 heading-driven 的 turn / brake / orbit / direct candidate 族、spring progress、独立 visual dynamics 和 debug UI;显式保留“主朝向跟随速度方向、额外角度 offset 单独叠加”的姿态结构,并把当前可见朝向与最终 resting pose 一起参与选路,避免出现与官方视频不符的原地翻转或 S 形扭曲回环。
+- 这条线优先验证 motion model 本身:当前主线是 heading-driven 的 turn / brake / orbit / direct candidate 族、spring progress、独立 visual dynamics 和 debug UI;内部 heading 仍会参与选路,但真正画出来的箭头角度已经收紧到更接近默认 cursor 的静止姿态,不再像车头一样持续指向移动方向,只在转弯时给一点 lean,并在停住后做原地小摆角。
+- lab 的 cursor 视觉当前单独参考 `scripts/render-synthesized-software-cursor.swift`:优先使用仓库里保存的官方 `252x252` runtime baseline 图,缺失时再退回脚本里的 procedural pointer/fog 近似;settle 态也改成中心固定的小幅摆角,而不是继续沿 XY 轻微漂移。
- 当前它不接真实 tool call,也不回写主 `SoftwareCursorOverlay`,目的是把实验噪音与产品行为边界隔离开。
## 关键边界
diff --git a/docs/exec-plans/active/20260418-standalone-cursor-lab.md b/docs/exec-plans/active/20260418-standalone-cursor-lab.md
index 3bae3fe..bf9c26b 100644
--- a/docs/exec-plans/active/20260418-standalone-cursor-lab.md
+++ b/docs/exec-plans/active/20260418-standalone-cursor-lab.md
@@ -65,6 +65,8 @@
- 2026-04-19:已把 lab 从 speculative slider 驱动的曲线/收尾模型,重构为 recovered 的 `20` candidate path + 官方风格 spring progress + 独立 visual dynamics;收尾不再靠 endpoint 锁住后原地翻角。
- 2026-04-19:在对照官方视频后发现 guide/arc 相关常量不能直接按屏幕坐标向量使用;当前已改成先投到 start→end 的局部基底,再生成候选路径,默认样例和反向斜移都不再出现起点附近打结式的扭曲回环。
- 2026-04-19:继续对照官方视频后,确认 lab 主线不能直接拿 raw reverse-engineered `20` candidates 当 chooser;当前已改成 heading-driven 选路,把当前可见朝向和最终 resting pose 一起参与选路,主路径重新收敛到“需要掉头时走单侧 C 形,不需要掉头时近直线”的分布。
+- 2026-04-20:在对照 `scripts/render-synthesized-software-cursor.swift` 与用户截图后,确认共享 glyph renderer 的亮白 asset 风格并不对;当前已把 lab 改成优先显示仓库里的官方 `252x252` runtime baseline 图,fallback 才走脚本同款 procedural pointer/fog,同时把 idle 从 XY 漂移收紧为中心固定的小幅摆角。
+- 2026-04-20:继续按用户反馈收紧姿态后,lab 现在把“内部 heading”与“可见箭头角度”分离;选路仍可参考当前 heading,但屏幕上看到的箭头不再像车头一样沿切线持续转向,只在转弯时轻微 lean。
## 决策记录
diff --git a/docs/histories/2026-04/20260418-1430-standalone-cursor-lab.md b/docs/histories/2026-04/20260418-1430-standalone-cursor-lab.md
index b48cf67..b5d3f8e 100644
--- a/docs/histories/2026-04/20260418-1430-standalone-cursor-lab.md
+++ b/docs/histories/2026-04/20260418-1430-standalone-cursor-lab.md
@@ -63,6 +63,39 @@
- **[同步 runtime overlay 选路]**: 主 `SoftwareCursorOverlay` 现在也改为同一套 heading-driven candidate 族;raw reverse-engineered `20` candidates 仍然保留在 `StandaloneCursor` / Python 重建脚本里做分析对照,但不再直接作为 runtime 主 chooser。
- **[补方向约束回归测试]**: 新增测试,显式验证“朝向已对齐时优先近直线”和“起步朝向反向时优先掉头大弧”两类行为,避免后续再次回到怪异扭曲曲线。
+### 🔁 Follow-up (2026-04-20, synthesized overlay style)
+**Scope:** `experiments/StandaloneCursorLab/`、`Package.swift`、`docs/`
+
+**Key Actions:**
+- **[改回脚本同款视觉]**: 对照用户给出的 `render-synthesized-software-cursor.swift` 参考图后,确认 lab 当前复用的亮白 asset 风格不对;改为优先显示仓库中的官方 `252x252` runtime baseline 图,并在缺失时退回脚本同款 procedural pointer/fog。
+- **[收紧 settle 态]**: `CursorMotionSimulator` 的 idle 不再做 XY 漂移,而是保持位置固定,只保留中心固定的小幅摆角,贴近脚本默认档的“原地轻微转动”。
+- **[撤回错误文档描述]**: README、架构说明和 execution plan 不再声称 lab 复用 `SoftwareCursorKit` 的共享 glyph renderer,改成明确引用脚本化 baseline/procedural renderer。
+
+### 📁 Additional Files Modified
+- `Package.swift`
+- `experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/CursorGlyphCalibration.swift`
+- `experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/CursorLabRootView.swift`
+- `experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/CursorMotionModel.swift`
+- `experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/SynthesizedCursorGlyphView.swift`
+- `experiments/StandaloneCursorLab/README.md`
+- `docs/ARCHITECTURE.md`
+- `docs/exec-plans/active/20260418-standalone-cursor-lab.md`
+
+### 🔁 Follow-up (2026-04-20, decouple visible arrow angle)
+**Scope:** `experiments/StandaloneCursorLab/`、`docs/`
+
+**Key Actions:**
+- **[分离内部 heading 与可见角度]**: 保留 motion model 内部 `rotation` 给下一段选路参考,但新增单独的 `displayRotation` 给 glyph 渲染,避免箭头在移动时像车头一样持续指向轨迹方向。
+- **[改成轻微 lean]**: moving 阶段的可见角度现在只根据 turn dynamics 给一个很小的偏转;idle 阶段仍然保留原地小摆角。
+- **[同步文档说法]**: README、架构说明和 active plan 不再把 lab 当前表现描述成“箭头主朝向明显跟随运动方向”。
+
+### 📁 Additional Files Modified
+- `experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/CursorMotionModel.swift`
+- `experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/CursorLabRootView.swift`
+- `experiments/StandaloneCursorLab/README.md`
+- `docs/ARCHITECTURE.md`
+- `docs/exec-plans/active/20260418-standalone-cursor-lab.md`
+
### 🔁 Follow-up (2026-04-20)
**Scope:** `experiments/StandaloneCursorLab/`、`docs/`
@@ -71,7 +104,6 @@
- **[收紧 DEBUG 关闭态]**: `DEBUG` 关闭后不再保留选中主轨迹或目标点 marker,整层调试 overlay 会一起隐藏,避免非调试模式下仍残留轨迹线和圆点。
- **[主视觉改为中性灰紫]**: 把 lab 的背景渐变、调试高亮和控件 accent 从原先偏粉色的方案切到接近 `#E3E2E6` 的中性灰紫配色,避免画面继续带明显粉色倾向。
-
### 📁 Additional Files Modified
- `experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/CursorLabRootView.swift`
- `experiments/StandaloneCursorLab/README.md`
diff --git a/experiments/StandaloneCursorLab/README.md b/experiments/StandaloneCursorLab/README.md
index 28d50ba..b821a84 100644
--- a/experiments/StandaloneCursorLab/README.md
+++ b/experiments/StandaloneCursorLab/README.md
@@ -18,6 +18,8 @@
- 独立 visual dynamics,用 visible tip/velocity/angle/fog 来驱动姿态
- `Sources/CursorLabRootView.swift`
- 本地 demo UI、候选路径 overlay、`REPLAY` 与点击交互
+- `Sources/SynthesizedCursorGlyphView.swift`
+ - 参考 `scripts/render-synthesized-software-cursor.swift` 的 baseline/procedural cursor renderer
## 当前参考
@@ -38,13 +40,14 @@ swift run StandaloneCursorLab
- 点击画布任意位置,先预览当前 heading-driven candidate 族,再自动选一路径并驱动 cursor 过去。
- `REPLAY` 会从固定起点重新跑同一条选中路径,便于反复观察收尾曲线和姿态变化。
- debug overlay 会显示控制点、arc handle 和当前选中的 candidate id / score。
+- 关闭 `DEBUG` 后不会展示任何轨迹线或目标点,只保留 cursor 本体,便于单独观察最终运动观感。
- lab 主线不再直接复用 raw binary lift 的 `20` 条 candidate + score;当前改为 reverse-engineering 约束下的 heading-driven chooser,把起始朝向和最终 resting pose 一起喂给路径选择器,让默认曲线更稳定收敛到单侧 C 形或近直线。
- 主路径进度不再用 speculative `easeInOut` 或 terminal settle;现在直接复用官方风格 spring progress。
-- 关闭 `DEBUG` 后不会展示任何轨迹线或目标点,只保留 cursor 本体,便于单独观察最终运动观感。
- 可见 cursor 不再直接贴在 path sample 上,而是经过独立 visual dynamics 状态,再输出 `rotation + cursorBodyOffset + fogOffset + fogScale`。
- 候选路径现在显式约束“先顺车头方向掉头,再沿主轴推进,再按 resting pose 收尾”;因此大多数跨向移动会呈现单侧 C 形,需要直接切入时才会退化为近直线,而不会再出现两侧乱甩的 S 形扭曲。
-- 箭头主朝向会重新明显跟随运动方向;小幅摆动单独作为额外 angle offset 叠加,而不是把整套 rotation 压成一个小角度 wiggle。
-- 使用 target 自带资源里的 cursor asset 渲染指针,并用 tip-anchor 而不是整张图中心来对齐点击点。
+- 箭头的可见角度不再像“车头”一样持续指向移动方向;当前会保留更接近默认 cursor 的静止姿态,只在转弯时给一点轻微 lean,并在停住后继续做原地小摆角。
+- cursor glyph 不再走之前那套亮白 asset;当前优先直接显示仓库里的官方 `252x252` runtime baseline 图,缺失时才退回脚本同款 procedural pointer/fog。
+- settle 态不再做 XY 漂移;现在改成和参考脚本一致的中心固定小摆角,让“停住以后原地轻微转动”的观感先对齐。
后续实现应优先保持:
diff --git a/experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/CursorGlyphCalibration.swift b/experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/CursorGlyphCalibration.swift
index 1f3869d..9440e76 100644
--- a/experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/CursorGlyphCalibration.swift
+++ b/experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/CursorGlyphCalibration.swift
@@ -1,4 +1,3 @@
-import AppKit
import CoreGraphics
enum CursorGlyphCalibration {
@@ -6,26 +5,10 @@ enum CursorGlyphCalibration {
static let restingRotation = -26.5 * CGFloat.pi / 180
}
-enum CursorGlyphArtwork {
- static let layoutSize = CGSize(width: 72, height: 72)
- static let imageSize = CGSize(width: 34, height: 34)
- static let imageOrigin = CGPoint(
- x: (layoutSize.width - imageSize.width) * 0.5,
- y: 8
- )
- static let tipAnchor = CGPoint(
- x: imageOrigin.x + (imageSize.width * 0.5),
- y: imageOrigin.y + 1
- )
- static let contentOffset = CGSize(
- width: (layoutSize.width * 0.5) - tipAnchor.x,
- height: (layoutSize.height * 0.5) - tipAnchor.y
- )
+enum SynthesizedCursorOverlayMetrics {
+ static let windowSize = CGSize(width: 126, height: 126)
+}
- static let image: NSImage? = {
- guard let url = Bundle.module.url(forResource: "StandaloneCursorPointer", withExtension: "png") else {
- return nil
- }
- return NSImage(contentsOf: url)
- }()
+enum SynthesizedCursorIdleStyle {
+ static let wobbleAmplitude = CGFloat.pi / 12
}
diff --git a/experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/CursorLabRootView.swift b/experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/CursorLabRootView.swift
index e1deae6..c853a1f 100644
--- a/experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/CursorLabRootView.swift
+++ b/experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/CursorLabRootView.swift
@@ -108,6 +108,7 @@ final class CursorLabViewModel: ObservableObject {
@Published private(set) var currentState = CursorMotionState(
point: CGPoint(x: 220, y: 440),
rotation: CursorGlyphCalibration.restingRotation,
+ displayRotation: CursorGlyphCalibration.restingRotation,
cursorBodyOffset: .zero,
fogOffset: .zero,
fogOpacity: CursorVisualDynamicsConfiguration.officialInspired.fogOpacityBase,
@@ -351,7 +352,7 @@ private struct CursorLabCanvas: View {
}
CursorGlyph(
- rotation: model.currentState.rotation,
+ rotation: model.currentState.displayRotation,
cursorBodyOffset: model.currentState.cursorBodyOffset,
fogOffset: model.currentState.fogOffset,
fogOpacity: model.currentState.fogOpacity,
@@ -529,81 +530,52 @@ private struct CursorGlyph: View {
let fogScale: CGFloat
let clickPulse: CGFloat
- private var motionCompression: CGFloat {
- min(hypot(cursorBodyOffset.dx, cursorBodyOffset.dy) * 0.01, 0.02)
- }
-
- private var clickCompression: CGFloat {
- clickPulse * 0.04
- }
-
var body: some View {
ZStack {
- Ellipse()
- .fill(Color.white.opacity(fogOpacity))
- .frame(width: 20 * fogScale, height: 10 * fogScale)
- .offset(x: fogOffset.dx, y: 18 + fogOffset.dy)
- .blur(radius: 6)
-
- glyphBody
- .offset(x: cursorBodyOffset.dx, y: cursorBodyOffset.dy)
- .shadow(color: Color.black.opacity(0.14), radius: 8, x: 0, y: 4)
-
- if clickPulse > 0.02 {
- Circle()
- .stroke(Color.white.opacity(0.26), lineWidth: 1)
- .frame(width: 8 + clickPulse * 12, height: 8 + clickPulse * 12)
- }
+ SynthesizedCursorGlyphRepresentable(
+ rotation: rotation,
+ cursorBodyOffset: cursorBodyOffset,
+ fogOffset: fogOffset,
+ fogOpacity: fogOpacity,
+ fogScale: fogScale,
+ clickProgress: clickPulse
+ )
+ .frame(
+ width: SynthesizedCursorOverlayMetrics.windowSize.width,
+ height: SynthesizedCursorOverlayMetrics.windowSize.height
+ )
}
- .frame(width: CursorGlyphArtwork.layoutSize.width, height: CursorGlyphArtwork.layoutSize.height)
- .rotationEffect(.radians(rotation), anchor: .center)
- .scaleEffect(
- x: 1 - clickCompression - motionCompression,
- y: 1 + (clickPulse * 0.03) + motionCompression,
- anchor: .center
+ .frame(
+ width: SynthesizedCursorOverlayMetrics.windowSize.width,
+ height: SynthesizedCursorOverlayMetrics.windowSize.height
)
}
-
- @ViewBuilder
- private var glyphBody: some View {
- if let image = CursorGlyphArtwork.image {
- Image(nsImage: image)
- .resizable()
- .interpolation(.high)
- .antialiased(true)
- .frame(width: CursorGlyphArtwork.imageSize.width, height: CursorGlyphArtwork.imageSize.height)
- .offset(CursorGlyphArtwork.contentOffset)
- } else {
- CursorGlyphFallbackShape()
- .fill(Color.black.opacity(0.92))
- .frame(width: CursorGlyphArtwork.imageSize.width, height: CursorGlyphArtwork.imageSize.height)
- .offset(CursorGlyphArtwork.contentOffset)
- }
- }
}
-private struct CursorGlyphFallbackShape: Shape {
- func path(in rect: CGRect) -> Path {
- Path { path in
- path.move(to: CGPoint(x: rect.midX, y: rect.minY))
- path.addQuadCurve(
- to: CGPoint(x: rect.maxX, y: rect.maxY * 0.86),
- control: CGPoint(x: rect.maxX * 0.92, y: rect.maxY * 0.28)
- )
- path.addQuadCurve(
- to: CGPoint(x: rect.midX, y: rect.maxY * 0.62),
- control: CGPoint(x: rect.maxX * 0.82, y: rect.maxY * 1.02)
- )
- path.addQuadCurve(
- to: CGPoint(x: rect.minX, y: rect.maxY * 0.86),
- control: CGPoint(x: rect.maxX * 0.18, y: rect.maxY * 1.02)
- )
- path.addQuadCurve(
- to: CGPoint(x: rect.midX, y: rect.minY),
- control: CGPoint(x: rect.maxX * 0.08, y: rect.maxY * 0.28)
+private struct SynthesizedCursorGlyphRepresentable: NSViewRepresentable {
+ let rotation: CGFloat
+ let cursorBodyOffset: CGVector
+ let fogOffset: CGVector
+ let fogOpacity: CGFloat
+ let fogScale: CGFloat
+ let clickProgress: CGFloat
+
+ func makeNSView(context: Context) -> SynthesizedCursorGlyphView {
+ SynthesizedCursorGlyphView(
+ frame: CGRect(
+ origin: .zero,
+ size: SynthesizedCursorOverlayMetrics.windowSize
)
- path.closeSubpath()
- }
+ )
+ }
+
+ func updateNSView(_ nsView: SynthesizedCursorGlyphView, context: Context) {
+ nsView.rotation = rotation
+ nsView.cursorBodyOffset = cursorBodyOffset
+ nsView.fogOffset = fogOffset
+ nsView.fogOpacity = fogOpacity
+ nsView.fogScale = fogScale
+ nsView.clickProgress = clickProgress
}
}
diff --git a/experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/CursorMotionModel.swift b/experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/CursorMotionModel.swift
index f22cd18..82721f8 100644
--- a/experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/CursorMotionModel.swift
+++ b/experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/CursorMotionModel.swift
@@ -1192,6 +1192,7 @@ struct CursorVisualDynamicsConfiguration: Equatable {
let angleSpring: CursorVisualSpringConfiguration
let headingVelocityFloor: CGFloat
let animatedAngleOffsetMax: CGFloat
+ let visibleTurnLeanMax: CGFloat
let bodyOffsetScale: CGFloat
let bodyOffsetMax: CGFloat
let bodyLateralScale: CGFloat
@@ -1207,7 +1208,8 @@ struct CursorVisualDynamicsConfiguration: Equatable {
tipSpring: CursorVisualSpringConfiguration(response: 0.18, dampingFraction: 0.76),
angleSpring: CursorVisualSpringConfiguration(response: 0.24, dampingFraction: 0.82),
headingVelocityFloor: 14,
- animatedAngleOffsetMax: 0.26,
+ animatedAngleOffsetMax: 0.28,
+ visibleTurnLeanMax: 0.085,
bodyOffsetScale: 0.0012,
bodyOffsetMax: 2.4,
bodyLateralScale: 0.06,
@@ -1252,6 +1254,7 @@ struct CursorVisualDynamicsState: Equatable {
struct CursorVisualRenderState: Equatable {
let tipPosition: CGPoint
let rotation: CGFloat
+ let visibleRotationOffset: CGFloat
let cursorBodyOffset: CGVector
let fogOffset: CGVector
let fogOpacity: CGFloat
@@ -1370,6 +1373,16 @@ enum CursorVisualDynamicsAnimator {
speed * configuration.fogScaleVelocityScale,
configuration.fogScaleMaxDelta
)
+ let visibleRotationOffset: CGFloat
+ if speed > configuration.headingVelocityFloor {
+ visibleRotationOffset = CGFloat.clamped(
+ (lateralAmount / max(configuration.bodyLateralMax, 0.001)) * configuration.visibleTurnLeanMax,
+ lower: -configuration.visibleTurnLeanMax,
+ upper: configuration.visibleTurnLeanMax
+ )
+ } else {
+ visibleRotationOffset = idleAngleOffset
+ }
return CursorVisualRenderState(
tipPosition: state.tipPosition,
@@ -1378,6 +1391,7 @@ enum CursorVisualDynamicsAnimator {
to: -configuration.animatedAngleOffsetMax...configuration.animatedAngleOffsetMax
)
),
+ visibleRotationOffset: visibleRotationOffset,
cursorBodyOffset: cursorBodyOffset,
fogOffset: fogOffset,
fogOpacity: fogOpacity,
@@ -1415,6 +1429,7 @@ enum CursorVisualDynamicsAnimator {
struct CursorMotionState: Equatable {
let point: CGPoint
let rotation: CGFloat
+ let displayRotation: CGFloat
let cursorBodyOffset: CGVector
let fogOffset: CGVector
let fogOpacity: CGFloat
@@ -1538,13 +1553,9 @@ final class CursorMotionSimulator {
case let .idle(restingTipPosition):
idlePhase += clampedDelta * 3
- let targetTipPosition = CGPoint(
- x: restingTipPosition.x + (sin(idlePhase) * 1.6),
- y: restingTipPosition.y + (cos(idlePhase * 0.47) * 0.7)
- )
- let idleAngleOffset = sin(idlePhase * 0.8) * 0.03
+ let idleAngleOffset = sin(idlePhase * 0.8) * SynthesizedCursorIdleStyle.wobbleAmplitude
let renderState = advanceVisualDynamics(
- toward: targetTipPosition,
+ toward: restingTipPosition,
idleAngleOffset: idleAngleOffset
)
return makeMotionState(renderState: renderState, trailProgress: 1, isSettled: true)
@@ -1584,6 +1595,7 @@ final class CursorMotionSimulator {
CursorMotionState(
point: renderState.tipPosition,
rotation: CursorGlyphCalibration.restingRotation + renderState.rotation,
+ displayRotation: CursorGlyphCalibration.restingRotation + renderState.visibleRotationOffset,
cursorBodyOffset: renderState.cursorBodyOffset,
fogOffset: renderState.fogOffset,
fogOpacity: renderState.fogOpacity,
diff --git a/experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/Resources/StandaloneCursorPointer.png b/experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/Resources/StandaloneCursorPointer.png
deleted file mode 100644
index 626e1f0..0000000
Binary files a/experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/Resources/StandaloneCursorPointer.png and /dev/null differ
diff --git a/experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/SynthesizedCursorGlyphView.swift b/experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/SynthesizedCursorGlyphView.swift
new file mode 100644
index 0000000..047d599
--- /dev/null
+++ b/experiments/StandaloneCursorLab/Sources/StandaloneCursorLab/SynthesizedCursorGlyphView.swift
@@ -0,0 +1,239 @@
+import AppKit
+import CoreGraphics
+import Foundation
+
+private enum SynthesizedCursorColors {
+ static let pointerFill = NSColor(calibratedRed: 0.38, green: 0.36, blue: 0.35, alpha: 0.98)
+ static let pointerStroke = NSColor(calibratedWhite: 0.90, alpha: 0.92)
+}
+
+@MainActor
+final class SynthesizedCursorGlyphView: NSView {
+ var rotation: CGFloat = 0 {
+ didSet { needsDisplay = true }
+ }
+
+ var cursorBodyOffset: CGVector = .zero {
+ didSet { needsDisplay = true }
+ }
+
+ var fogOffset: CGVector = .zero {
+ didSet { needsDisplay = true }
+ }
+
+ var fogOpacity: CGFloat = 0.12 {
+ didSet { needsDisplay = true }
+ }
+
+ var fogScale: CGFloat = 1 {
+ didSet { needsDisplay = true }
+ }
+
+ var clickProgress: CGFloat = 0 {
+ didSet { needsDisplay = true }
+ }
+
+ private let referenceImage = loadReferenceCursorWindowImage()
+
+ override init(frame frameRect: NSRect) {
+ super.init(frame: frameRect)
+ wantsLayer = true
+ layer?.isOpaque = false
+ }
+
+ @available(*, unavailable)
+ required init?(coder: NSCoder) {
+ fatalError("init(coder:) has not been implemented")
+ }
+
+ override var isOpaque: Bool {
+ false
+ }
+
+ override func draw(_ dirtyRect: NSRect) {
+ super.draw(dirtyRect)
+
+ NSColor.clear.setFill()
+ dirtyRect.fill()
+
+ guard let context = NSGraphicsContext.current?.cgContext else {
+ return
+ }
+
+ if let referenceImage {
+ drawReferenceImage(referenceImage, in: context)
+ return
+ }
+
+ drawProceduralGlyph(in: context)
+ }
+
+ private func drawReferenceImage(_ image: NSImage, in context: CGContext) {
+ let motionCompression = min(hypot(cursorBodyOffset.dx, cursorBodyOffset.dy) * 0.008, 0.018)
+ let pulseCompression = clickProgress * 0.03
+
+ context.saveGState()
+ context.translateBy(
+ x: bounds.midX + cursorBodyOffset.dx,
+ y: bounds.midY + cursorBodyOffset.dy
+ )
+ context.rotate(by: rotation - CursorGlyphCalibration.restingRotation)
+ context.scaleBy(
+ x: 1 - motionCompression - pulseCompression,
+ y: 1 + (pulseCompression * 0.4)
+ )
+ context.translateBy(x: -bounds.midX, y: -bounds.midY)
+ image.draw(in: bounds, from: .zero, operation: .sourceOver, fraction: 1)
+ context.restoreGState()
+ }
+
+ private func drawProceduralGlyph(in context: CGContext) {
+ let pulse = clickProgress
+ let fogCenter = CGPoint(
+ x: bounds.midX + fogOffset.dx,
+ y: bounds.midY + fogOffset.dy
+ )
+ let pointerCenter = CGPoint(
+ x: bounds.midX + 2.6 + cursorBodyOffset.dx,
+ y: bounds.midY - 3.2 + cursorBodyOffset.dy + (pulse * 0.35)
+ )
+
+ drawFog(in: context, center: fogCenter, pulse: pulse)
+ drawPointer(in: context, center: pointerCenter, pulse: pulse)
+ }
+
+ private func drawFog(in context: CGContext, center: CGPoint, pulse: CGFloat) {
+ let radius = ((66 * fogScale) / 2) + (pulse * 1.2)
+ let glowRadius = radius * (0.30 + (pulse * 0.025))
+ let opacityMultiplier = max(0.28, min(fogOpacity / 0.12, 2.2))
+ let colors = [
+ NSColor(calibratedRed: 0.38, green: 0.36, blue: 0.35, alpha: (0.40 + (pulse * 0.02)) * opacityMultiplier).cgColor,
+ NSColor(calibratedRed: 0.43, green: 0.41, blue: 0.40, alpha: (0.28 + (pulse * 0.015)) * opacityMultiplier).cgColor,
+ NSColor(calibratedRed: 0.46, green: 0.44, blue: 0.43, alpha: 0.11 * opacityMultiplier).cgColor,
+ NSColor(calibratedWhite: 0.60, alpha: 0.0).cgColor,
+ ] as CFArray
+ let locations: [CGFloat] = [0, 0.50, 0.82, 1]
+ let colorSpace = CGColorSpaceCreateDeviceRGB()
+
+ guard let gradient = CGGradient(colorsSpace: colorSpace, colors: colors, locations: locations) else {
+ return
+ }
+
+ context.saveGState()
+ context.drawRadialGradient(
+ gradient,
+ startCenter: center,
+ startRadius: 0,
+ endCenter: center,
+ endRadius: radius,
+ options: [.drawsBeforeStartLocation, .drawsAfterEndLocation]
+ )
+ context.restoreGState()
+
+ let coreColors = [
+ NSColor(calibratedRed: 0.41, green: 0.39, blue: 0.38, alpha: (0.020 + (pulse * 0.006)) * opacityMultiplier).cgColor,
+ NSColor(calibratedRed: 0.44, green: 0.41, blue: 0.40, alpha: 0.008 * opacityMultiplier).cgColor,
+ NSColor(calibratedWhite: 0.80, alpha: 0.0).cgColor,
+ ] as CFArray
+ let coreLocations: [CGFloat] = [0, 0.62, 1]
+ guard let coreGradient = CGGradient(colorsSpace: colorSpace, colors: coreColors, locations: coreLocations) else {
+ return
+ }
+
+ context.saveGState()
+ context.drawRadialGradient(
+ coreGradient,
+ startCenter: center,
+ startRadius: 0,
+ endCenter: center,
+ endRadius: glowRadius,
+ options: [.drawsBeforeStartLocation, .drawsAfterEndLocation]
+ )
+ context.restoreGState()
+ }
+
+ private func drawPointer(in context: CGContext, center: CGPoint, pulse: CGFloat) {
+ let pointerRect = CGRect(
+ x: center.x - 10.5,
+ y: center.y - 10.5,
+ width: 21,
+ height: 21
+ )
+ let outerPath = pointerPath(in: pointerRect)
+
+ context.saveGState()
+ context.translateBy(x: bounds.midX + cursorBodyOffset.dx, y: bounds.midY + cursorBodyOffset.dy)
+ context.rotate(by: rotation - CursorGlyphCalibration.restingRotation)
+ context.scaleBy(x: 1 - (pulse * 0.04), y: 1 + (pulse * 0.02))
+ context.translateBy(x: -(bounds.midX + cursorBodyOffset.dx), y: -(bounds.midY + cursorBodyOffset.dy))
+
+ NSGraphicsContext.saveGraphicsState()
+ let shadow = NSShadow()
+ shadow.shadowBlurRadius = 3.2 + (pulse * 1.4)
+ shadow.shadowOffset = CGSize(width: 0, height: -0.35)
+ shadow.shadowColor = NSColor.black.withAlphaComponent(0.11)
+ shadow.set()
+ NSColor.black.withAlphaComponent(0.05).setFill()
+ outerPath.fill()
+ NSGraphicsContext.restoreGraphicsState()
+
+ SynthesizedCursorColors.pointerFill.setFill()
+ outerPath.fill()
+
+ SynthesizedCursorColors.pointerStroke.setStroke()
+ outerPath.lineWidth = 1.55
+ outerPath.lineJoinStyle = .round
+ outerPath.lineCapStyle = .round
+ outerPath.stroke()
+
+ context.restoreGState()
+ }
+
+ private func pointerPath(in rect: CGRect) -> NSBezierPath {
+ let contourRows: [(y: CGFloat, minX: CGFloat, maxX: CGFloat)] = [
+ (39, 17, 21), (38, 16, 22), (37, 15, 22), (36, 15, 23), (35, 15, 24),
+ (34, 15, 24), (33, 14, 25), (32, 14, 25), (31, 14, 26), (30, 14, 27),
+ (29, 13, 29), (28, 13, 31), (27, 13, 34), (26, 13, 36), (25, 13, 37),
+ (24, 12, 37), (23, 12, 37), (22, 12, 37), (21, 12, 37), (20, 12, 36),
+ (19, 11, 36), (18, 11, 34), (17, 11, 32), (16, 11, 30), (15, 10, 27),
+ (14, 10, 25), (13, 10, 23), (12, 11, 21), (11, 11, 19), (10, 13, 16),
+ ]
+ let sourceMinX: CGFloat = 10
+ let sourceMaxX: CGFloat = 38
+ let sourceMinY: CGFloat = 10
+ let sourceMaxY: CGFloat = 39
+
+ func mappedPoint(x: CGFloat, y: CGFloat) -> CGPoint {
+ CGPoint(
+ x: rect.minX + ((x - sourceMinX) / (sourceMaxX - sourceMinX) * rect.width),
+ y: rect.minY + ((y - sourceMinY) / (sourceMaxY - sourceMinY) * rect.height)
+ )
+ }
+
+ let leftBoundary = contourRows.map { mappedPoint(x: $0.minX, y: $0.y) }
+ let rightBoundary = contourRows.reversed().map { mappedPoint(x: $0.maxX, y: $0.y) }
+
+ let path = NSBezierPath()
+ path.move(to: leftBoundary[0])
+ leftBoundary.dropFirst().forEach { path.line(to: $0) }
+ rightBoundary.forEach { path.line(to: $0) }
+ path.close()
+ path.lineJoinStyle = .round
+ return path
+ }
+}
+
+private func loadReferenceCursorWindowImage() -> NSImage? {
+ let fileURL = URL(fileURLWithPath: #filePath).standardizedFileURL
+ let repoRoot = fileURL
+ .deletingLastPathComponent()
+ .deletingLastPathComponent()
+ .deletingLastPathComponent()
+ .deletingLastPathComponent()
+ .deletingLastPathComponent()
+
+ let referenceURL = repoRoot
+ .appendingPathComponent("docs/references/codex-computer-use-reverse-engineering/assets/extracted-2026-04-19/official-software-cursor-window-252.png")
+
+ return NSImage(contentsOf: referenceURL)
+}