tui-designer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

TUI Designer - Retro/Cyberpunk Terminal UI Expert

TUI Designer - 复古/赛博朋克终端UI专家

Expert guidance for designing and implementing text-based user interfaces with authentic retro computing aesthetics: CRT monitors, phosphor glow, scanlines, and cyberpunk neon.
提供专业指导,帮助你设计并实现带有纯正复古计算美学的文本类用户界面:CRT显示器效果、磷光发光、扫描线、赛博朋克霓虹特效。

When to Use This Skill

适用场景

Use this skill when:
  • Creating terminal-style or hacker aesthetic UIs
  • Implementing CRT monitor effects (scanlines, glow, barrel distortion)
  • Building cyberpunk/synthwave/retrowave interfaces
  • Using Tuimorphic components in React
  • Implementing Metal shaders for retro effects in SwiftUI
  • Designing neon glow text and UI elements
  • Choosing color palettes for retro computing aesthetics
  • Working with monospace fonts and box-drawing characters
当你遇到以下需求时可使用本指南:
  • 打造终端风格或黑客美学UI
  • 实现CRT显示器特效(扫描线、发光、桶形畸变)
  • 构建赛博朋克/合成波/复古波风格界面
  • 在React中使用Tuimorphic组件
  • 在SwiftUI中实现Metal着色器复古特效
  • 设计霓虹发光文本及UI元素
  • 为复古计算美学选择配色方案
  • 使用等宽字体和盒绘字符

Design Principles

设计原则

The Retro/Cyberpunk Aesthetic

复古/赛博朋克美学

This aesthetic draws from:
  • CRT monitors: Phosphor glow, scanlines, screen curvature, flicker
  • Terminal interfaces: Monospace fonts, box-drawing characters, green/amber text
  • Cyberpunk fiction: Neon colors, dark backgrounds, high contrast
  • 1980s computing: ASCII art, limited color palettes, blocky graphics
这类美学的灵感来源包括:
  • CRT显示器:磷光发光、扫描线、屏幕曲率、闪烁效果
  • 终端界面:等宽字体、盒绘字符、绿色/琥珀色文本
  • 赛博朋克科幻作品:霓虹色彩、深色背景、高对比度
  • 1980年代计算设备:ASCII艺术、有限配色、块状图形

Visual Elements Checklist

视觉元素检查清单

  • Dark background (near-black with subtle color tint)
  • Monospace typography throughout
  • Box-drawing characters for borders and frames
  • Neon glow on text and/or borders
  • Scanline effect (subtle horizontal lines)
  • Limited color palette (1-3 accent colors)
  • High contrast between text and background
  • Optional: CRT curvature, chromatic aberration, flicker
  • 深色背景(接近纯黑,带有微妙色调)
  • 全局使用等宽字体
  • 使用盒绘字符制作边框和框架
  • 文本和/或边框添加霓虹发光效果
  • 扫描线效果(细微的水平线)
  • 有限配色方案(1-3个强调色)
  • 文本与背景高对比度
  • 可选:CRT曲率、色差、闪烁效果

Quick Reference: Color Palettes

快速参考:配色方案

Phosphor Green (Classic Terminal)

磷光绿(经典终端)

RoleHexUsage
Bright
#00ff00
Primary text, highlights
Medium
#00cc00
Secondary text
Dark
#009900
Dimmed elements
Background
#001100
Main background
Deep BG
#000800
Panel backgrounds
角色Hex用途
亮色
#00ff00
主文本、高亮内容
中度色
#00cc00
次要文本
暗色
#009900
弱化元素
背景色
#001100
主背景
深层背景
#000800
面板背景

Cyberpunk Neon

赛博朋克霓虹

RoleHexUsage
Cyan
#00ffff
Primary accent
Magenta
#ff00ff
Secondary accent
Electric Blue
#0066ff
Tertiary
Hot Pink
#ff1493
Warnings
Background
#0a0a1a
Main background
角色Hex用途
青色
#00ffff
主强调色
洋红色
#ff00ff
次强调色
电光蓝
#0066ff
第三强调色
亮粉色
#ff1493
警告提示
背景色
#0a0a1a
主背景

Amber CRT

琥珀色CRT

RoleHexUsage
Bright
#ffb000
Primary text
Medium
#cc8800
Secondary
Dark
#996600
Dimmed
Background
#1a1000
Main background
See color-palettes.md for complete specifications.
角色Hex用途
亮色
#ffb000
主文本
中度色
#cc8800
次要内容
暗色
#996600
弱化元素
背景色
#1a1000
主背景
查看 color-palettes.md 获取完整规范。

Typography

排版

Recommended Fonts

推荐字体

Web:
css
font-family: 'GNU Unifont', 'IBM Plex Mono', 'JetBrains Mono',
             'SF Mono', 'Consolas', monospace;
SwiftUI:
swift
.font(.system(size: 14, weight: .regular, design: .monospaced))
Web端:
css
font-family: 'GNU Unifont', 'IBM Plex Mono', 'JetBrains Mono',
             'SF Mono', 'Consolas', monospace;
SwiftUI端:
swift
.font(.system(size: 14, weight: .regular, design: .monospaced))

Box-Drawing Characters

盒绘字符

Light:   ─ │ ┌ ┐ └ ┘ ├ ┤ ┬ ┴ ┼
Heavy:   ━ ┃ ┏ ┓ ┗ ┛ ┣ ┫ ┳ ┻ ╋
Double:  ═ ║ ╔ ╗ ╚ ╝ ╠ ╣ ╦ ╩ ╬
Rounded: ╭ ╮ ╰ ╯
See typography-guide.md for complete reference.
Light:   ─ │ ┌ ┐ └ ┘ ├ ┤ ┬ ┴ ┼
Heavy:   ━ ┃ ┏ ┓ ┗ ┛ ┣ ┫ ┳ ┻ ╋
Double:  ═ ║ ╔ ╗ ╚ ╝ ╠ ╣ ╦ ╩ ╬
Rounded: ╭ ╮ ╰ ╯
查看 typography-guide.md 获取完整参考。

Copywriting

文案撰写

Terminal interfaces have a distinct voice: terse, technical, authoritative. Use these defaults unless the project specifies otherwise.
终端界面有独特的语气风格:简洁、专业、权威。除非项目另有规定,否则请遵循以下默认规则。

Core Principles

核心原则

  1. Terse and Direct - Every word earns its place
  2. Technical Authority - The system knows what it's doing
  3. Mechanical Precision - No hedging, apologies, or filler
  1. 简洁直接 - 没有冗余内容
  2. 专业权威 - 系统功能清晰明确
  3. 机械精准 - 没有模糊表述、道歉语或填充内容

Text Formatting

文本格式

ElementCaseExample
Headers/TitlesUPPERCASE
SYSTEM STATUS
LabelsUPPERCASE
CPU USAGE:
Status indicatorsUPPERCASE
ONLINE
,
OFFLINE
Commands/Inputlowercase
> run diagnostic
Body textSentence case
Connection established
元素大小写格式示例
表头/标题全大写
SYSTEM STATUS
标签全大写
CPU USAGE:
状态指示器全大写
ONLINE
,
OFFLINE
命令/输入全小写
> run diagnostic
正文文本首字母大写
Connection established

Message Prefixes

消息前缀

[SYS] System message       [ERR] Error
[USR] User action          [WRN] Warning
[INF] Information          [NET] Network
[SYS] 系统消息       [ERR] 错误
[USR] 用户操作       [WRN] 警告
[INF] 信息提示       [NET] 网络相关

Vocabulary Quick Reference

词汇快速参考

ActionTerminal Verbs
StartINITIALIZE, BOOT, LAUNCH, ACTIVATE
StopTERMINATE, HALT, ABORT, KILL
SaveWRITE, COMMIT, STORE, PERSIST
LoadREAD, FETCH, RETRIEVE, LOAD
DeletePURGE, REMOVE, CLEAR, WIPE
StateTerminal Words
WorkingPROCESSING, EXECUTING, RUNNING
DoneCOMPLETE, SUCCESS, FINISHED
FailedERROR, FAULT, ABORTED
ReadyONLINE, AVAILABLE, ARMED
操作终端动词
启动INITIALIZE, BOOT, LAUNCH, ACTIVATE
停止TERMINATE, HALT, ABORT, KILL
保存WRITE, COMMIT, STORE, PERSIST
加载READ, FETCH, RETRIEVE, LOAD
删除PURGE, REMOVE, CLEAR, WIPE
状态终端词汇
处理中PROCESSING, EXECUTING, RUNNING
已完成COMPLETE, SUCCESS, FINISHED
失败ERROR, FAULT, ABORTED
就绪ONLINE, AVAILABLE, ARMED

Common Patterns

常见模式

> INITIALIZING SYSTEM...
> LOADING MODULES [████████░░] 80%
> AUTHENTICATION COMPLETE
> SYSTEM READY

ERROR: ACCESS DENIED
ERR_CONNECTION_REFUSED: Timeout after 30s
WARNING: Low disk space (< 10%)

CONFIRM DELETE? [Y/N]
SELECT OPTION [1-5]:
> INITIALIZING SYSTEM...
> LOADING MODULES [████████░░] 80%
> AUTHENTICATION COMPLETE
> SYSTEM READY

ERROR: ACCESS DENIED
ERR_CONNECTION_REFUSED: Timeout after 30s
WARNING: Low disk space (< 10%)

CONFIRM DELETE? [Y/N]
SELECT OPTION [1-5]:

Avoid

避免使用

  • "Please", "Sorry", "Oops"
  • "Just", "Maybe", "Might"
  • Excessive exclamation points
  • Emoji (unless specifically requested)
See copywriting-guide.md for complete voice and tone reference.

  • "请"、"抱歉"、"哎呀"这类表述
  • "仅"、"可能"、"也许"这类模糊词汇
  • 过多感叹号
  • 表情符号(除非明确要求)
查看 copywriting-guide.md 获取完整的语气风格参考。

Platform: React with Tuimorphic

平台:基于Tuimorphic的React实现

Tuimorphic is a React component library providing 37 terminal-styled, accessible UI components.
Tuimorphic是一个React组件库,提供37个终端风格、可访问的UI组件。

Quick Start

快速开始

bash
npm install tuimorphic
tsx
import { Button, Card, Input } from 'tuimorphic';
import 'tuimorphic/styles.css';

function App() {
  return (
    <div className="theme-dark tint-green">
      <Card>
        <h1>SYSTEM ACCESS</h1>
        <Input placeholder="Enter command..." />
        <Button variant="primary">EXECUTE</Button>
      </Card>
    </div>
  );
}
bash
npm install tuimorphic
tsx
import { Button, Card, Input } from 'tuimorphic';
import 'tuimorphic/styles.css';

function App() {
  return (
    <div className="theme-dark tint-green">
      <Card>
        <h1>SYSTEM ACCESS</h1>
        <Input placeholder="Enter command..." />
        <Button variant="primary">EXECUTE</Button>
      </Card>
    </div>
  );
}

Theme Configuration

主题配置

Apply themes via CSS classes on a parent element:
jsx
// Dark mode with green tint
<div className="theme-dark tint-green">

// Light mode with cyan tint
<div className="theme-light tint-blue">
Available tints:
tint-green
,
tint-blue
,
tint-red
,
tint-yellow
,
tint-purple
,
tint-orange
,
tint-pink
通过父元素的CSS类应用主题:
jsx
// 深色模式 + 绿色调
<div className="theme-dark tint-green">

// 浅色模式 + 青色调
<div className="theme-light tint-blue">
可用色调:
tint-green
,
tint-blue
,
tint-red
,
tint-yellow
,
tint-purple
,
tint-orange
,
tint-pink

Key Components

核心组件

ComponentUsage
Button
Actions with
variant="primary|secondary|ghost"
Input
Text input with terminal styling
Card
Container with box-drawing borders
Dialog
Modal dialogs
Menu
Dropdown menus
CodeBlock
Syntax-highlighted code
Table
Data tables
Tabs
Tabbed navigation
TreeView
File tree display
See tuimorphic-reference.md for complete API.
组件用途
Button
操作按钮,支持
variant="primary|secondary|ghost"
Input
终端风格的文本输入框
Card
带盒绘边框的容器
Dialog
模态对话框
Menu
下拉菜单
CodeBlock
带语法高亮的代码块
Table
数据表格
Tabs
标签导航
TreeView
文件树展示
查看 tuimorphic-reference.md 获取完整API。

Adding Neon Glow

添加霓虹发光效果

Enhance Tuimorphic with CSS glow effects:
css
/* Neon text glow */
.neon-text {
  color: #0ff;
  text-shadow:
    0 0 5px #fff,
    0 0 10px #fff,
    0 0 20px #0ff,
    0 0 40px #0ff,
    0 0 80px #0ff;
}

/* Neon border glow */
.neon-border {
  border-color: #0ff;
  box-shadow:
    0 0 5px #0ff,
    0 0 10px #0ff,
    inset 0 0 5px #0ff;
}

/* Flickering animation */
@keyframes flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.95; }
  52% { opacity: 1; }
  54% { opacity: 0.9; }
}

.flicker {
  animation: flicker 3s infinite;
}

使用CSS发光效果增强Tuimorphic组件:
css
/* 霓虹文本发光 */
.neon-text {
  color: #0ff;
  text-shadow:
    0 0 5px #fff,
    0 0 10px #fff,
    0 0 20px #0ff,
    0 0 40px #0ff,
    0 0 80px #0ff;
}

/* 霓虹边框发光 */
.neon-border {
  border-color: #0ff;
  box-shadow:
    0 0 5px #0ff,
    0 0 10px #0ff,
    inset 0 0 5px #0ff;
}

/* 闪烁动画 */
@keyframes flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.95; }
  52% { opacity: 1; }
  54% { opacity: 0.9; }
}

.flicker {
  animation: flicker 3s infinite;
}

Platform: SwiftUI with Metal Shaders

平台:基于Metal着色器的SwiftUI实现

iOS 17+ supports Metal shaders directly in SwiftUI via
.colorEffect()
,
.distortionEffect()
, and
.layerEffect()
.
iOS 17+支持通过
.colorEffect()
.distortionEffect()
.layerEffect()
在SwiftUI中直接使用Metal着色器。

CRT Effect Implementation

CRT效果实现

CRT.metal:
metal
#include <metal_stdlib>
#include <SwiftUI/SwiftUI.h>
using namespace metal;

[[stitchable]] half4 crtEffect(
    float2 position,
    SwiftUI::Layer layer,
    float time,
    float2 size,
    float scanlineIntensity,
    float distortionStrength
) {
    float2 uv = position / size;

    // Barrel distortion
    float2 center = uv - 0.5;
    float dist = length(center);
    float2 distorted = center * (1.0 + distortionStrength * dist * dist);
    float2 samplePos = (distorted + 0.5) * size;

    // Bounds check
    if (samplePos.x < 0 || samplePos.x > size.x ||
        samplePos.y < 0 || samplePos.y > size.y) {
        return half4(0, 0, 0, 1);
    }

    // Sample color
    half4 color = layer.sample(samplePos);

    // Scanlines
    float scanline = sin(position.y * 3.14159 * 2.0) * scanlineIntensity;
    color.rgb *= 1.0 - scanline;

    // Subtle color shift (chromatic aberration)
    color.r *= 1.0 + 0.02 * sin(time * 2.0);
    color.b *= 1.0 - 0.02 * sin(time * 2.0);

    // Slight flicker
    color.rgb *= 1.0 + 0.01 * sin(time * 60.0);

    return color;
}
SwiftUI View Modifier:
swift
struct CRTEffectModifier: ViewModifier {
    @State private var startTime = Date()
    var scanlineIntensity: Float = 0.1
    var distortionStrength: Float = 0.1

    func body(content: Content) -> some View {
        TimelineView(.animation) { timeline in
            let time = Float(timeline.date.timeIntervalSince(startTime))
            GeometryReader { geo in
                content
                    .layerEffect(
                        ShaderLibrary.crtEffect(
                            .float(time),
                            .float2(geo.size),
                            .float(scanlineIntensity),
                            .float(distortionStrength)
                        ),
                        maxSampleOffset: .init(width: 10, height: 10)
                    )
            }
        }
    }
}

extension View {
    func crtEffect(
        scanlines: Float = 0.1,
        distortion: Float = 0.1
    ) -> some View {
        modifier(CRTEffectModifier(
            scanlineIntensity: scanlines,
            distortionStrength: distortion
        ))
    }
}
Usage:
swift
Text("SYSTEM ONLINE")
    .font(.system(size: 24, weight: .bold, design: .monospaced))
    .foregroundColor(.green)
    .crtEffect(scanlines: 0.15, distortion: 0.08)
CRT.metal:
metal
#include <metal_stdlib>
#include <SwiftUI/SwiftUI.h>
using namespace metal;

[[stitchable]] half4 crtEffect(
    float2 position,
    SwiftUI::Layer layer,
    float time,
    float2 size,
    float scanlineIntensity,
    float distortionStrength
) {
    float2 uv = position / size;

    // 桶形畸变
    float2 center = uv - 0.5;
    float dist = length(center);
    float2 distorted = center * (1.0 + distortionStrength * dist * dist);
    float2 samplePos = (distorted + 0.5) * size;

    // 边界检查
    if (samplePos.x < 0 || samplePos.x > size.x ||
        samplePos.y < 0 || samplePos.y > size.y) {
        return half4(0, 0, 0, 1);
    }

    // 采样颜色
    half4 color = layer.sample(samplePos);

    // 扫描线效果
    float scanline = sin(position.y * 3.14159 * 2.0) * scanlineIntensity;
    color.rgb *= 1.0 - scanline;

    // 细微色彩偏移(色差)
    color.r *= 1.0 + 0.02 * sin(time * 2.0);
    color.b *= 1.0 - 0.02 * sin(time * 2.0);

    // 轻微闪烁
    color.rgb *= 1.0 + 0.01 * sin(time * 60.0);

    return color;
}
SwiftUI视图修饰符:
swift
struct CRTEffectModifier: ViewModifier {
    @State private var startTime = Date()
    var scanlineIntensity: Float = 0.1
    var distortionStrength: Float = 0.1

    func body(content: Content) -> some View {
        TimelineView(.animation) { timeline in
            let time = Float(timeline.date.timeIntervalSince(startTime))
            GeometryReader { geo in
                content
                    .layerEffect(
                        ShaderLibrary.crtEffect(
                            .float(time),
                            .float2(geo.size),
                            .float(scanlineIntensity),
                            .float(distortionStrength)
                        ),
                        maxSampleOffset: .init(width: 10, height: 10)
                    )
            }
        }
    }
}

extension View {
    func crtEffect(
        scanlines: Float = 0.1,
        distortion: Float = 0.1
    ) -> some View {
        modifier(CRTEffectModifier(
            scanlineIntensity: scanlines,
            distortionStrength: distortion
        ))
    }
}
使用示例:
swift
Text("SYSTEM ONLINE")
    .font(.system(size: 24, weight: .bold, design: .monospaced))
    .foregroundColor(.green)
    .crtEffect(scanlines: 0.15, distortion: 0.08)

Neon Glow in SwiftUI

SwiftUI中的霓虹发光效果

swift
extension View {
    func neonGlow(color: Color, radius: CGFloat = 10) -> some View {
        self
            .shadow(color: color.opacity(0.8), radius: radius / 4)
            .shadow(color: color.opacity(0.6), radius: radius / 2)
            .shadow(color: color.opacity(0.4), radius: radius)
            .shadow(color: color.opacity(0.2), radius: radius * 2)
    }
}

// Usage
Text("NEON")
    .font(.system(size: 48, design: .monospaced))
    .foregroundColor(.cyan)
    .neonGlow(color: .cyan, radius: 15)
See metal-shaders-ios.md for complete shader code.

swift
extension View {
    func neonGlow(color: Color, radius: CGFloat = 10) -> some View {
        self
            .shadow(color: color.opacity(0.8), radius: radius / 4)
            .shadow(color: color.opacity(0.6), radius: radius / 2)
            .shadow(color: color.opacity(0.4), radius: radius)
            .shadow(color: color.opacity(0.2), radius: radius * 2)
    }
}

// 用法
Text("NEON")
    .font(.system(size: 48, design: .monospaced))
    .foregroundColor(.cyan)
    .neonGlow(color: .cyan, radius: 15)
查看 metal-shaders-ios.md 获取完整着色器代码。

Platform: CSS/Vanilla Web

平台:CSS/原生Web实现

Scanlines Overlay

扫描线覆盖层

css
.crt-container {
    position: relative;
    background: #000800;
}

.crt-container::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
}
css
.crt-container {
    position: relative;
    background: #000800;
}

.crt-container::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
}

Neon Text Effect

霓虹文本效果

css
.neon-text {
    color: #0ff;
    text-shadow:
        /* White core */
        0 0 5px #fff,
        0 0 10px #fff,
        /* Colored glow layers */
        0 0 20px #0ff,
        0 0 30px #0ff,
        0 0 40px #0ff,
        0 0 55px #0ff,
        0 0 75px #0ff;
}
css
.neon-text {
    color: #0ff;
    text-shadow:
        /* 白色核心 */
        0 0 5px #fff,
        0 0 10px #fff,
        /* 彩色发光层 */
        0 0 20px #0ff,
        0 0 30px #0ff,
        0 0 40px #0ff,
        0 0 55px #0ff,
        0 0 75px #0ff;
}

CRT Curvature (CSS Transform)

CRT曲率(CSS Transform实现)

css
.crt-screen {
    border-radius: 20px;
    transform: perspective(1000px) rotateX(2deg);
    box-shadow:
        inset 0 0 50px rgba(0, 255, 0, 0.1),
        0 0 20px rgba(0, 255, 0, 0.2);
}
css
.crt-screen {
    border-radius: 20px;
    transform: perspective(1000px) rotateX(2deg);
    box-shadow:
        inset 0 0 50px rgba(0, 255, 0, 0.1),
        0 0 20px rgba(0, 255, 0, 0.2);
}

WebGL CRT with CRTFilter.js

基于CRTFilter.js的WebGL CRT效果

html
<script type="module">
import { CRTFilterWebGL } from 'crtfilter';

const canvas = document.getElementById('crt-canvas');
const crt = new CRTFilterWebGL(canvas, {
    scanlineIntensity: 0.15,
    glowBloom: 0.3,
    chromaticAberration: 0.002,
    barrelDistortion: 0.1,
    staticNoise: 0.03,
    flicker: true,
    retraceLines: true
});

crt.start();
</script>
See crt-effects-web.md for complete techniques.

html
<script type="module">
import { CRTFilterWebGL } from 'crtfilter';

const canvas = document.getElementById('crt-canvas');
const crt = new CRTFilterWebGL(canvas, {
    scanlineIntensity: 0.15,
    glowBloom: 0.3,
    chromaticAberration: 0.002,
    barrelDistortion: 0.1,
    staticNoise: 0.03,
    flicker: true,
    retraceLines: true
});

crt.start();
</script>
查看 crt-effects-web.md 获取完整实现技巧。

Effect Patterns

效果实现模式

Scanlines

扫描线

PlatformImplementation
CSS
repeating-linear-gradient
pseudo-element
SwiftUIMetal shader with
sin(position.y * frequency)
WebGLFragment shader brightness modulation
平台实现方案
CSS
repeating-linear-gradient
伪元素
SwiftUI基于
sin(position.y * frequency)
的Metal着色器
WebGL片元着色器亮度调制

Bloom/Glow

Bloom/发光效果

PlatformImplementation
CSSMultiple
text-shadow
with increasing blur
SwiftUIMultiple
.shadow()
modifiers
WebGLGaussian blur pass + additive blend
Three.js
UnrealBloomPass
with
luminanceThreshold
平台实现方案
CSS多层叠加不同模糊半径的
text-shadow
SwiftUI多层
.shadow()
修饰符
WebGL高斯模糊通道 + 加法混合
Three.js
luminanceThreshold
参数的
UnrealBloomPass

Chromatic Aberration

色差效果

PlatformImplementation
CSSThree overlapping elements with color channel offset
SwiftUISample texture at offset positions per RGB channel
WebGLSample UV with slight offset per channel
平台实现方案
CSS三个重叠元素,每个通道设置不同偏移
SwiftUI每个RGB通道单独采样偏移位置的纹理
WebGL每个通道采样UV时添加轻微偏移

Flicker

闪烁效果

PlatformImplementation
CSS
@keyframes
animation varying opacity 0.9-1.0
SwiftUITimer-driven opacity or shader time-based
WebGLTime-based noise multiplier

平台实现方案
CSS
@keyframes
动画控制透明度在0.9-1.0之间变化
SwiftUI定时器驱动透明度变化或基于着色器时间参数实现
WebGL基于时间的噪点乘数

Performance Considerations

性能注意事项

CSS Effects

CSS特效

  • box-shadow
    and
    text-shadow
    are GPU-accelerated but expensive with many layers
  • Limit to 4-5 shadow layers for glow effects
  • Use
    will-change: transform
    for animated elements
  • Consider
    prefers-reduced-motion
    media query
  • box-shadow
    text-shadow
    是GPU加速的,但多层叠加时性能开销较大
  • 发光效果最多使用4-5层阴影
  • 为动画元素添加
    will-change: transform
    属性
  • 考虑适配
    prefers-reduced-motion
    媒体查询

SwiftUI/Metal

SwiftUI/Metal

  • Metal shaders run at 60-120fps on all devices supporting iOS 17+
  • .layerEffect()
    processes every pixel - keep shaders simple
  • Pre-compile shaders with
    .compile()
    (iOS 18+)
  • Test on older devices (A12 minimum for iOS 17)
  • Metal着色器在所有支持iOS 17+的设备上都能达到60-120fps的运行效率
  • .layerEffect()
    会处理每个像素,尽量保持着色器逻辑简单
  • 使用
    .compile()
    预编译着色器(iOS 18+支持)
  • 在旧设备上测试(iOS 17最低支持A12芯片)

WebGL

WebGL

  • CRTFilter.js uses hardware acceleration, minimal performance impact
  • Bloom effects in Three.js require render-to-texture passes
  • Consider lower resolution render targets for mobile
  • CRTFilter.js使用硬件加速,性能影响极小
  • Three.js中的发光效果需要渲染到纹理的步骤
  • 移动端可考虑使用更低分辨率的渲染目标

General

通用建议

  • Reduce effect intensity on mobile devices
  • Provide option to disable effects for accessibility
  • Profile with actual content, not just empty screens

  • 在移动端降低特效强度
  • 提供关闭特效的选项以提升可访问性
  • 使用真实内容而非空页面进行性能测试

Templates

模板

Ready-to-use starter files:
  • react-tuimorphic-starter.tsx - React app with Tuimorphic
  • swiftui-crt-view.swift - SwiftUI view with CRT effect
  • crt-shader.metal - Complete Metal shader
  • neon-glow.css - CSS neon effects

开箱即用的启动文件:
  • react-tuimorphic-starter.tsx - 集成Tuimorphic的React应用
  • swiftui-crt-view.swift - 带有CRT效果的SwiftUI视图
  • crt-shader.metal - 完整Metal着色器
  • neon-glow.css - CSS霓虹特效

Resources

资源

Libraries

类库

Documentation

文档

Inspiration

灵感参考