feat(design): 应用明亮指标配色与不透明实色面板

This commit is contained in:
2026-11-03 13:11:57 +08:00
parent df96d6853f
commit 92e8187038
19 changed files with 201 additions and 132 deletions
+18 -8
View File
@@ -1,27 +1,37 @@
import AppKit
@main struct PanelAssetChecks {
static func luminance(_ color: NSColor) -> Double {
func linear(_ x: CGFloat) -> Double {
let value = Double(x)
return value <= 0.04045 ? value / 12.92 : pow((value + 0.055) / 1.055, 2.4)
}
return 0.2126 * linear(color.redComponent) + 0.7152 * linear(color.greenComponent) + 0.0722 * linear(color.blueComponent)
}
static func main() {
let bundle = Bundle(path: CommandLine.arguments[1])!
for appearance in [NSAppearance.Name.aqua, .darkAqua] {
NSAppearance(named: appearance)!.performAsCurrentDrawingAppearance {
for name in ["PanelCard", "PanelTooltip", "MetricCPU", "MetricGPU", "MetricMemory", "MetricNetwork", "MetricDisk", "MetricBattery", "SeriesUser", "SeriesSystem", "SeriesUpload"] {
for name in ["PanelBackground", "PanelCard", "PanelTooltip", "MetricCPU", "MetricGPU", "MetricMemory", "MetricNetwork", "MetricDisk", "MetricBattery", "SeriesUser", "SeriesSystem", "SeriesUpload"] {
guard let color = NSColor(named: NSColor.Name(name), bundle: bundle)?.usingColorSpace(.sRGB) else { fatalError("Missing color: \(name)") }
precondition(abs(color.alphaComponent - (name == "PanelCard" ? 0.68 : name == "PanelTooltip" ? 0.97 : 1)) < 0.005, "Unexpected alpha \(name)")
if name == "MetricGPU" && appearance == .darkAqua { precondition(color.blueComponent > 0.99) }
precondition(abs(color.alphaComponent - (name == "PanelTooltip" ? 0.97 : 1)) < 0.005, "Unexpected alpha \(name)")
if name.hasPrefix("Metric") || name.hasPrefix("Series") {
let card = NSColor(named: "PanelCard", bundle: bundle)!.usingColorSpace(.sRGB)!
let a = luminance(color), b = luminance(card)
precondition((max(a, b) + 0.05) / (min(a, b) + 0.05) >= 3, "Insufficient graphical contrast: \(name) / \(appearance)")
}
}
let names = ["MetricCPU", "SeriesUser", "SeriesSystem"]
let colors = names.map { NSColor(named: NSColor.Name($0), bundle: bundle)!.usingColorSpace(.sRGB)! }
for i in 0..<colors.count {
for j in (i + 1)..<colors.count {
let distance = pow(colors[i].redComponent - colors[j].redComponent, 2)
+ pow(colors[i].greenComponent - colors[j].greenComponent, 2)
+ pow(colors[i].blueComponent - colors[j].blueComponent, 2)
precondition(distance > 0.25, "CPU series hues too close")
let delta = abs(colors[i].hueComponent - colors[j].hueComponent)
precondition(min(delta, 1 - delta) >= 0.1, "CPU series hues too close")
}
}
}
}
print("PASS: compiled light/dark semantic colors exist, card translucent/semantic colors opaque, GPU blue component is normalized")
print("PASS: compiled light/dark semantic colors exist, panel/card opaque, semantic colors opaque, CPU series distinct and graphical contrast >= 3:1")
}
}
+1 -1
View File
@@ -134,7 +134,7 @@ swiftc -parse-as-library -module-cache-path /private/tmp/kymo-unified-cache \
/private/tmp/kymo-panel-asset-checks /absolute/path/to/kymo.app
```
前者覆盖屏幕预算、边界约束和 2000 行投影,不证明原生定位或滚动手感;后者读取编译资源,防止整数色值被解释为 1/255,并确认卡片半透明、指标色不透明。
前者覆盖屏幕预算、边界约束和 2000 行投影,不证明原生定位或滚动手感;后者读取编译资源,确认主面板/卡片不透明、浮层资源保留既有透明度,检查 CPU 三序列色相间隔至少 36°,以及所有指标/序列颜色对卡片背景的图形对比度至少 3:1。
复合图几何检查(真实时间追加、满历史平移、暂停断线、缺失/非有限值):